How to pass data in a variable from webapp js to workflow js using postevent | Community
Skip to main content
New Participant
Dec 1, 2022 2:15 PM UTC
Solved

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

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.

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
david--garcia
david--garciaAccepted solution
Level 10
Dec 4, 2022 1:07 AM UTC

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)

4 replies

Sukrity_Wadhwa
Employee
Dec 12, 2022 3:06 PM UTC

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!

Translate
Sukrity Wadhwa
david--garcia
david--garciaAccepted solution
Level 10
Dec 4, 2022 1:07 AM UTC

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)

Translate
Marcel_Szimonisz
New Participant
Dec 2, 2022 10:03 AM UTC

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/

Translate
AkshayAnand
New Participant
Dec 1, 2022 3:58 PM UTC

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

Translate