Skip to main content
Heku_
Level 5
Mar 29, 2023 10:50 AM UTC
Solved

Send target to a transition from advanced javascript

Hello, i have an advanced javascript code like this.

I have 3 transitions, and the 15 targets go to the 3 transitions, but i would like the language == "es" to go to the transition Es, and the language == "en" to go to the transition En, how can i do it?

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
AkshayAnand
AkshayAnandAccepted solution
Community Advisor
Mar 29, 2023 1:38 PM UTC

Hi @alnavarg 

 

I tried running a similar code and got the desired results.

var query = xtk.queryDef.create( <queryDef schema={vars.targetSchema} operation="select"> <select> <node expr="@id"/> <node expr="@lastName"/> </select> </queryDef> ); var resultSet = query.ExecuteQuery(); for each (var row in resultSet) { var condition = row.@lastName; logInfo(condition); if(condition == 'Test') { task.postEvent(task.transitionByName('english')); } else { task.postEvent(task.transitionByName('other')); } }

 

When you look in the transitions it will show all the records but if you do a log in individual END activities, you can see the desired no. of records being processed.

 

 

As per my record, only one record satisfied the English transition condition hence one log for English END activity.

I would request you to once try logging in the END activity and see if the desired results are being processed.

 

Regards

A

 

16 replies

Level 3
Mar 29, 2023 11:23 AM UTC

In your for each loop you need to declare the language variable.
Instead of:

language = e.language

 try:

var language = e.language

 

Translate
alnavarg
Level 4
Mar 29, 2023 12:11 PM UTC

The problem persists

 

Any other solution?

Translate
AkshayAnand
Community Advisor
AkshayAnandCommunity AdvisorAccepted solution
Community Advisor
Mar 29, 2023 1:38 PM UTC

Hi @alnavarg 

 

I tried running a similar code and got the desired results.

var query = xtk.queryDef.create( <queryDef schema={vars.targetSchema} operation="select"> <select> <node expr="@id"/> <node expr="@lastName"/> </select> </queryDef> ); var resultSet = query.ExecuteQuery(); for each (var row in resultSet) { var condition = row.@lastName; logInfo(condition); if(condition == 'Test') { task.postEvent(task.transitionByName('english')); } else { task.postEvent(task.transitionByName('other')); } }

 

When you look in the transitions it will show all the records but if you do a log in individual END activities, you can see the desired no. of records being processed.

 

 

As per my record, only one record satisfied the English transition condition hence one log for English END activity.

I would request you to once try logging in the END activity and see if the desired results are being processed.

 

Regards

A

 

Translate