How to pass data in a variable from webapp js to workflow js using postevent | Community
Skip to main content
New Participant
December 1, 2022
Solved

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

  • December 1, 2022
  • 4 replies
  • 1420 views

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.
Best answer by david--garcia

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
December 12, 2022

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
david--garcia
david--garciaAccepted solution
New Participant
December 4, 2022

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)

Marcel_Szimonisz
New Participant
December 2, 2022

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/

AkshayAnand
New Participant
December 1, 2022

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