Send target to a transition from advanced javascript | Community
Skip to main content
Heku_
Level 5
March 29, 2023
Solved

Send target to a transition from advanced javascript

  • March 29, 2023
  • 1 reply
  • 3877 views

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

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

 

1 reply

Level 3
March 29, 2023

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

language = e.language

 try:

var language = e.language

 

alnavarg
Level 4
March 29, 2023

The problem persists

 

Any other solution?

alnavarg
Level 4
March 30, 2023

Hi @alnavarg 

 

If your use case is to send delivery based on the recipient language, then you can use the SPLIT activity to assign different segment codes to different target audience and use JSSP (<% targetData.SegementCode) %>) and call different personalization blocks containing the email content. 

 

Regards,

A


I want to do everything through javascript if possible, I do NOT want to use split,
I want a Js:
-I want to filter by languages
-Then that js will choose a delivery with that language and relate it to the delivery.
-That this delivery contains all the necessary to be able to send: To, Subject and the TEMPLATE.
-Finally send it to the filtered recipients.

Thanks

 

@akshayanand @_manoj_kumar_ @dwnuk@heku_ @campaignerforlife