Hi,
I am looking for a solution to update a record through a workflow (only to be kept in the workflow for later usage for export).
I am working on Adobe Campaign Classic v7 build 8797
So far I have been looking around and found a solution there is working (for someone else) on Standard.
I've tried to change it to the data I want to update but without luck.
This is the content of my JS
var schemaName = vars.targetSchema.substr(vars.targetSchema.indexOf(":") + 1);
logInfo(schemaName);
logInfo(vars.targetSchema);
var query = xtk.queryDef.create(
<queryDef schema={vars.targetSchema} operation="select">
<select>
<node expr="@id"/>
<node expr="@ProductDate"/>
</select>
</queryDef>
);
var resultSet = query.ExecuteQuery();
var collection = <{schemaName}-collection _operation="update" xtkschema={vars.targetSchema}/>;
for each (var row in resultSet) {
var ProductDate = formatDate(row.@ProductDate, "%2D%2M%4Y");
var schemaNameProgram = <{schemaName}-collection id={row.@id} ProductDate='ProductDate' _key='@id' xtkschema={vars.targetSchema}/>;
collection.appendChild(schemaNameProgram);
logInfo(ProductDate);
}
xtk.session.WriteCollection(collection);
Without any change I get this error
JST-310000 Error while compiling script 'WKF963/js' line 17: invalid XML tag syntax (line='var collection = <{schemaName}-collection _operation="update" xtkschema={vars.targetSchema}/>; ' token='-collection _operation="update" xtkschema={vars.targetSchema}/>; ').
SCR-160032 JavaScript: error while compiling script 'WKF963/js'.
When changing the {schemaName} to match my schema in the flow it runs without errors but does not update the record as expected.
Thanks in advance,
Best, Jonas
Jean-Serge Biron Amit_Kumar florentlb Adhiyan
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Deb,
I solved with another solution by changing the data stream and formatting through an enrichment step, where I changed the data from the fields and got the outcome in the flow data as expected.
This was done due to i could not get your solution to function as you described in your answers.
Best, Jonas
Hi Jonas,
If you only want to update the temp table and it can be achieved by sql, the following script in your js will work.
var sql = "UPDATE "+vars.tableName+" SET dProductdate = function(dProductdate ) ";
sqlExec(sql);
Using appropriate sql function you can you get it done.
Regards,
Deb
Hi Deb,
Thanks for the answer,
But i cant get this to work, as is?
My data field has the data: SQL field 'tsProductdate' of type 'Date' (Productdate)
And where should I place the js to format the date?
Hope you can help elaborate a bit further
Thanks in advance,
Best, Jonas
Views
Replies
Total Likes
Hi Jonas,
You can refer the following link to achieve date format change during export.
How to display date and time in UTC format i.e, 2018-05-02T13:47:33.743Z?
Regards,
Deb
Views
Replies
Total Likes
Hi Deb,
I solved with another solution by changing the data stream and formatting through an enrichment step, where I changed the data from the fields and got the outcome in the flow data as expected.
This was done due to i could not get your solution to function as you described in your answers.
Best, Jonas