Update record in workflow | Community
Skip to main content
Pabst_dk
Level 2
Nov 7, 2018 10:01 AM UTC
Solved

Update record in workflow

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​

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Pabst_dk
Pabst_dkAccepted solution
Level 2
Nov 18, 2018 6:36 PM UTC

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

4 replies

Pabst_dk
Pabst_dkAuthorAccepted solution
Level 2
Nov 18, 2018 6:36 PM UTC

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

Translate
Level 6
Nov 12, 2018 3:36 PM UTC

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

Translate
Pabst_dk
Pabst_dkAuthor
Level 2
Nov 12, 2018 1:59 PM UTC

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

Translate
Level 6
Nov 7, 2018 2:19 PM UTC

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

Translate