Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!
SOLVED

Update record in workflow

Avatar

Level 3

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 BironAmit_KumarflorentlbAdhiyan

1 Accepted Solution

Avatar

Correct answer by
Level 3

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

View solution in original post

4 Replies

Avatar

Community Advisor

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

Avatar

Level 3

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

Avatar

Community Advisor

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

Avatar

Correct answer by
Level 3

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