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

Writing work table data in a Temp Table

Avatar

Level 2

Hi -

 

I have created a Temp table via JS in my workflow and want to insert data from the working table in that temp table, is it possible?

 

If yes can you help me with JS for it?

 

Regards,

Tushar Varshney 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

 

You may fetch temp schema like this:

var schemaName = vars.targetSchema.substr(vars.targetSchema.indexOf(":") + 1);

logInfo(schemaName);

var query = xtk.queryDef.create(

<queryDef schema = {vars.targetSchema} operation = "select">

<select>

<node expr = "@firstName"/>

<node expr = "@lastName"/>

<node expr = "@email"/>

<node expr = "@id"/>

</select>

</queryDef>);

If you are sure in this above, you may try this for writing:

var some_variable = <vars.targetSchema.split(':')[1]

xtkschema = vars.targetSchema

_key="@id"

_operation="Update"

lastName = {record.lastName }

firstName={record.firstName}

email = {record.email }

/>;

xtk.session.Write(some_variable);

Thanks,

David



David Kangni

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

Hi,

 

You may fetch temp schema like this:

var schemaName = vars.targetSchema.substr(vars.targetSchema.indexOf(":") + 1);

logInfo(schemaName);

var query = xtk.queryDef.create(

<queryDef schema = {vars.targetSchema} operation = "select">

<select>

<node expr = "@firstName"/>

<node expr = "@lastName"/>

<node expr = "@email"/>

<node expr = "@id"/>

</select>

</queryDef>);

If you are sure in this above, you may try this for writing:

var some_variable = <vars.targetSchema.split(':')[1]

xtkschema = vars.targetSchema

_key="@id"

_operation="Update"

lastName = {record.lastName }

firstName={record.firstName}

email = {record.email }

/>;

xtk.session.Write(some_variable);

Thanks,

David



David Kangni

Avatar

Community Advisor

Hello @varshtus ,

 

I am assuming you have created a temp table with the JS and it is not created by any activity.

 

To read the data from the previous activity and store it in the temp table you can use this javascript code.

//reading the data rom the previous activity
var query = xtk.queryDef.create(<queryDef schema={vars.targetSchema} operation="select"><select><node expr="@id"/><node expr="@COLUMN1"/></select></queryDef>);
var resultSet = query.ExecuteQuery();


// Writing the data into the temp table

for each (var row in resultSet) {
     var COLUMN1= row.@COLUMN1;   
     var pId= row.@id;         
     sqlExec("INSERTO INTO TEMP_TABLE_NAME values("+COLUMN1+","+pID+"));
}

 

Let me know if that works.

 

Thanks

 

 

 


     Manoj
     Find me on LinkedIn

Avatar

Administrator

Hi @varshtus,

Were you able to resolve this query with any of the given solutions? Do let us know.

Thanks!



Sukrity Wadhwa