Hi,
I have used Javascript code to make a functional call using API. I have stored that value in a variable. Now, I'm trying to use the value to check if the value of variable is greater than static value and if yes, I want to go ahead in further step in workflow. If not, I want to end the workflow.
Also, I want to use the variable value in email delivery.
I have tried few things to do this however, I was just able to fetch variable in Javascript code block and after that, there are only errors.
Can anyone help with first part of question - that is, trying to check variable value against static value ?
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @vinay16 ,
You can use 'Advanced JavaScript Code' Activity for your use case.
Copy paste the script in Advanced JS, and pass your variable value as mentioned below,
vars.variable_Value= 1000; //Pass the Variable value here
vars.staticNumber = 100; //HardCode Static value here
if(vars.variable_Value > vars.staticNumber)
{
instance.vars.variable_Value = vars.variable_Value;
task.postEvent(task.transitionByName("ok"));
}
else
{
task.postEvent(task.transitionByName("no"));
}
To add the variable in Delivery,
1) Delivery > script tab,
delivery.variables._var[0].stringValue=instance.vars.variable_Value;
2) Delivery > Property > Variable's tab > Add > Name: variable_Value > Ok
3) Now you can call this variable in email body, Delivery Parameters > variable_Value
Hello @vinay16,
Take a look at this for taking variable to the delivery
https://experienceleaguecommunities.adobe.com/t5/adobe-campaign-classic-questions/how-to-display-a-w...
In any filtering condition you can bring the variable in by following expression
$(vars/@myvar)
$(instance/vars/@myvar)
Marcel
Hi @vinay16 ,
You can use 'Advanced JavaScript Code' Activity for your use case.
Copy paste the script in Advanced JS, and pass your variable value as mentioned below,
vars.variable_Value= 1000; //Pass the Variable value here
vars.staticNumber = 100; //HardCode Static value here
if(vars.variable_Value > vars.staticNumber)
{
instance.vars.variable_Value = vars.variable_Value;
task.postEvent(task.transitionByName("ok"));
}
else
{
task.postEvent(task.transitionByName("no"));
}
To add the variable in Delivery,
1) Delivery > script tab,
delivery.variables._var[0].stringValue=instance.vars.variable_Value;
2) Delivery > Property > Variable's tab > Add > Name: variable_Value > Ok
3) Now you can call this variable in email body, Delivery Parameters > variable_Value
Hi,
Thanks for your reply.
I have used "Advanced Javascript Code" and wrote the following code -
vars.jackpotAmount = function for fetching the value --- I was able to fetch the value.
After that I have used query in which I'm comparing the value of this variable against static value and I could get result out of this step as well. Also, added jackpotAmount as complementary information in this query.
In delivery - I have used <% targetData.jackpotAmount %> - but I am getting empty result. I am not sure what is the reason behind that?
Can you please help ?
I have attached relevant images.
Views
Replies
Total Likes
If you pause delivery and run the workflow can you see that variable populated in target data?
Views
Replies
Total Likes
I have disabled the delivery and open the delivery and I can still see the variable in target data. Did you mean to ask that?
If not, can you please tell me how I can check populated variable in target data after running workflow?
Views
Replies
Total Likes
Hi @vinay16 ,
As you had created @jackpotAmount using enrichment, Enable 'keep the interim result' in workflow property, and run the WKF.
Now Right click the enrichment transition > display the target > You can able to cross check here whether there is any value present for @jackpotAmount
I was able to implement the workflow with dummy accounts and ran workflow so I was able to fetch the data that way. Thank you so much..
Views
Replies
Total Likes
Hi @vinay16,
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!
It is done..
Views
Likes
Replies