Expand my Community achievements bar.

SOLVED

How to pass data in a variable from webapp js to workflow js using postevent

Avatar

Level 1

I need to pass variable from webapp js to workflow js , we are using an external signal to trigger the workflow from webapp javascript.

 

when we use vars.variablename 

xtk.workflow.PostEvent('calledWorkflow','signal','', <variables varName= {vars.xyz} />,false)

 

it shows an error in webapp as it does not allow vars.variablename.

 

we have also tried ctx variable but in the workflow it is coming as undefined.

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

On your webapp

var abc= ctx.vars.abc;
var xyz= ctx.vars.xyz;

NLWS.xtkWorkflow.PostEvent("yourworkflow", "yoursignal", "", {variables: {"abc":abc, "xyz" xyz, }}, false);

On your workflow

logInfo(vars.abc+vars.xyz)

View solution in original post

4 Replies

Avatar

Community Advisor

Hi @Prateek789

You can try storing the ctx variables in some variable (eg. var A = ctx.abc) and then try to call it in the Post event or you can also try storing the output in some Option Variables and use them in your workflow.

Regards

Avatar

Community Advisor

Hello @Prateek789 ,

webapps do not have worklfow variables like vars. or instance.vars. they use ctx.vars. the postEvent is correct just push local variable (var xyz) or push context variable to the function (ctx.vars.xyz)

Marcel Szimonisz

MarTech Consultant
for more tips visit my blog
https://www.martechnotes.com/

Avatar

Correct answer by
Community Advisor

On your webapp

var abc= ctx.vars.abc;
var xyz= ctx.vars.xyz;

NLWS.xtkWorkflow.PostEvent("yourworkflow", "yoursignal", "", {variables: {"abc":abc, "xyz" xyz, }}, false);

On your workflow

logInfo(vars.abc+vars.xyz)

Avatar

Administrator

Hi @Prateek789,

Were you able to resolve this query with the help of the given solutions or do you still need more help here? Do let us know. In case the given solutions were helpful, then kindly choose the one that helped you the most as the 'Correct Reply'.
Thanks!



Sukrity Wadhwa