Hello,
I created this script to update a field with a reformatted date.
Howeever, when I look at my output data, the field is still NULL, even though I can see from the DisplayLogs that I'm creating the data.
Please advise what I'm missing.
Views
Replies
Total Likes
Hello @montezh2001
The issue is with how the xtk.session.write method is written.
<vars.targetSchema is not correct syntax. Replace it with correct syntax.
Views
Replies
Total Likes
Manoj,
Sorry, I'm not well-versed on JS. However, even when I change my code to read from the schema name, I still get no output:
Please advise
Views
Replies
Total Likes
Date fields are typically of the UTC (Universal Time Code) type and must conform with that format. You cannot reformat a date and then write it back into such a field as it no longer matches the data type. Reformatted dates are typically used to write the date into another field, or as target.data in a delivery or into an output file.
Views
Replies
Total Likes
As you can see in my code that I'm reformatting the date into a string (MMMYYYY) and placing it into a field that is a string.
So still not sure why I can't see data. I've even tried the following code - and still get no results.
Views
Replies
Total Likes
Hello @montezh2001,
I see two issues in your xtk.session.Write, the "vars.targetSchema" should be " {vars.targetSchema.split(':')[1]} ", and the identifier used to update your rows. As i understand from your request, the identifier of your temporary table is "clientId" and not "id", so your script should look like this :
var query = xtk.queryDef.create( <queryDef schema={vars.targetSchema} operation="select"> <select> <node expr="@clientId"/> //or any identifier of the workflow's temporary table <node expr="@contractIssueDate"/> <node expr="@MMMYYYYDate"/> </select> </queryDef>); var results = query.ExecuteQuery(); for each( var tmp in results){ var res = tmp.@contractIssueDate; var Date1 = formatDate(res,"%B%Y").toString(); logInfo("MMMDate: "+Date1); xtk.session.Write(<{vars.targetSchema.split(':')[1]} _operation="update" _key="@clientId" xtkschema={vars.targetSchema} clientId={tmp.@clientId} MMMYYYYDate={Date1}/>); }
Br,
Amine
Views
Replies
Total Likes
Thank you for replying, but this is returning an error.
Here is a view of my WF:
I'm reading in a List, adding the @policyTenureMMMYYYY field in my Enrichment, and then trying to run the JS code to create/populate the @policyTenureMMMYYYY field.
Not sure why this will not work in Adobe, but this is beyond frustrating as either I try xtk.session.Write or sqlExec - I get the same results.
I've stated before that I'm not proficient in JS, but this code has worked for me before as I needed it to remove leading 0's from a field and output the new field. Now it's if ACC doesn't recognize the code and can't read from the data schema feeding into the JS.
Did something change in ACC that I'm not aware of?
Views
Replies
Total Likes
Also - here's the log of the Date field I'm creating -
So the field is creating - just not writing out.
Views
Replies
Total Likes
Hi @montezh2001 , Can you please share the complete js code once again, how it looks after making the above suggested changes?
Thanks,
Ishan
Views
Replies
Total Likes
Here's the latest iteration. It contains both codes I've tried.
Views
Replies
Total Likes
Hi @montezh2001 , can you please also paste the complete error log of this activity when run with this code? Maybe also the interim results before this activity, and the enrichment configuration where you added that field which you are trying to update?
Thanks,
Ishan
Views
Replies
Total Likes
Hello,
So I am able to get them to run with no error. Previous errors were all coding issues. But I will paste the log and Enrichment.
Views
Replies
Total Likes
Hi @montezh2001,
So I can see from your enrichment that the matchKey itself is made up of two fields.
Can you may be add these two fields in your select expression, and then use them as a composite key in your xtk.session.Write method? Like this below:
_key="@clientId,@contractId" and use both of them in your Write call.
So it would look something like this:
_key="@clientId,@contractId" clientId={tmp.@clientId} contractId={tmp.contractId}
This should resolve your problem. Let me know if that worked.
Thanks,
Ishan
Views
Replies
Total Likes
Ishan,
Still no results. It's a head scratcher for sure. The following is the revised JS Code, the log showing I'm creating the date, and the data field from the schema not being populated. I made one change to the JS Code and I'm now going to pick up the Date1 field.
Views
Replies
Total Likes
Hi @montezh2001,
Does the targetSchema has contractId and clientId coming from the database fields, or are they also derived from some other expression? Does your targetSchema has any other key fields?
It should work this way for sure.
Can you try one thing? Try to set some static value in the field when you add it in the enrichment. Later in your code it should get updated. If it still does not get updated, can you check the clientId and contractId values in the resulting data set?
Thanks,
Ishan
Views
Replies
Total Likes
I'm reading in a List, so the ClientId and ContractId are coming from there. I'll try your suggestion. Give me 15 minutes.
Views
Replies
Total Likes
Ishan,
I filled the Policy field with 'Null' and then ran the WF again. I'm getting results, but not for every record now. And the results seems to be inaccurate. Below is an example of a duplicate where I should have two different Policy Tenures.
So almost there. However, the majority of the file still is not updating.
Views
Replies
Total Likes
Hi @montezh2001,
Is the list of type "File" or is it linked to nms:recipient? Also, in case you are reading from a list, maybe it would work if you could update the related sql table of this list (if it is of type "File") and add this new field to the sql table. Then directly update data into this table using an SQL statement.
If it is linked to nms:recipient, then may be try querying on nms:recipient as the targeting dimension to get the recipients who are present in that list, and also adding the data from that list into your targetSchema via enrichment (I did not try this approach so far). Try and let me know.
Thanks,
Ishan
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies