Push Parameter values passed in a URL of a webapp to a workflow | Community
Skip to main content
September 6, 2023
Solved

Push Parameter values passed in a URL of a webapp to a workflow

  • September 6, 2023
  • 1 reply
  • 1287 views

Hi All,

 

I am working on a campaign workflow which sends out a notification email to the recipients. This email contains a button that has a webapp URL in it. This URL is also passing a parameter called as Email. Now when this button gets clicked, I want the parameter Email's value passed in the URL to be pushed to a campaign workflow. I have placed a postevent script for pushing the data from the webapp to this workflow. But somehow when i read the email variable in the workflow, I do not see any data being passed. Could you please share your insight on why the parameter value from the webapp is not be passed to the workflow? Also, I am not using any form in this webapp. This is just a confirmation page.Looking forward to your responses. Thanks!

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 AkshayAnand

Hi @milirawat 

 

You can define your parameter in the webapp Properties which will be a necessary field in the URL and will be passed in it. Also you need to define a variable which will store this parameter, in your case Email. in the variables tab of properties.

You can use a querydef to fetch the email of the record and assign it to a variable as below.

var query = xtk.queryDef.create( <queryDef schema="schemaName" operation="select"> <select> <node expr="@email"/> </select> <where> <condition expr={"[@email] ='"+ ctx.schemaName.@email+ "'"} /> </where> </queryDef>); var res = query.ExecuteQuery(); for each (var rcp in res) { ctx.vars.email=rcp.@email; //Variable defined in the variables tab of the webapp. }

 

After saving the the value into the variable you can use the postEvent method of workflow to post this variable as below :

logInfo("Email Variable is :"+ctx.vars.email); xtk.workflow.PostEvent("workflowInternalName", "signal", "", <variables email={ctx.vars.email} />, false);

 

Once this is posted successfully after publication of the webapp, you can access those variable in your desired workflow.

logInfo(vars.email);

 

Hope this helps.

 

Regards

Akshay

1 reply

AkshayAnand
Community Advisor
AkshayAnandCommunity AdvisorAccepted solution
Community Advisor
September 6, 2023

Hi @milirawat 

 

You can define your parameter in the webapp Properties which will be a necessary field in the URL and will be passed in it. Also you need to define a variable which will store this parameter, in your case Email. in the variables tab of properties.

You can use a querydef to fetch the email of the record and assign it to a variable as below.

var query = xtk.queryDef.create( <queryDef schema="schemaName" operation="select"> <select> <node expr="@email"/> </select> <where> <condition expr={"[@email] ='"+ ctx.schemaName.@email+ "'"} /> </where> </queryDef>); var res = query.ExecuteQuery(); for each (var rcp in res) { ctx.vars.email=rcp.@email; //Variable defined in the variables tab of the webapp. }

 

After saving the the value into the variable you can use the postEvent method of workflow to post this variable as below :

logInfo("Email Variable is :"+ctx.vars.email); xtk.workflow.PostEvent("workflowInternalName", "signal", "", <variables email={ctx.vars.email} />, false);

 

Once this is posted successfully after publication of the webapp, you can access those variable in your desired workflow.

logInfo(vars.email);

 

Hope this helps.

 

Regards

Akshay

jorgeferreira
Level 3
September 6, 2023

If the OP has the preloading activity, or in another way the variable he needs to pass into the workflow, he doesn't need to create a paramenter. 
Other than that it's bang on. 

The call to the workflow needs to be like this:

xtk.workflow.PostEvent("workflowInternalName", "signal", "", <variables email={ctx.vars.email} />, false);

And you can pass as much parameters as you'd like.