Expand my Community achievements bar.

SOLVED

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

Avatar

Level 1

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!

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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.

AkshayAnand_0-1693989869706.png

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

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

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.

AkshayAnand_0-1693989869706.png

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

Avatar

Level 3

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.