Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

ACC: script to update groups/lists dynamically

maurizio_coro
Level 3
Level 3

Hi guys,

I'm trying to update some already created lists dynamically.

Anyone has a js code to implement this activity?

The idea is to save the recipient list in these groups via an unique ID, so I guess I've to run a for...each but I have no idea on how to read and write via js

thanks

1 Accepted Solution
Jean-Serge_Biro
Correct answer by
Community Advisor
Community Advisor

Hi Maurizio,

If your need is to achieve this treatment in a workflow, I rather recommend you to use the OOTB "List update" activity.

Please see documentation:
How to use workflow data
Targeting activities

If you still need Javascript code to do the same for another reason, you can use the JSAPI nms.recipient.RegisterGroup function.
Please refer to the  JSAPI.chm documentation (restricted to license) for details.

Regards
J-Serge

View solution in original post

7 Replies
Jean-Serge_Biro
Correct answer by
Community Advisor
Community Advisor

Hi Maurizio,

If your need is to achieve this treatment in a workflow, I rather recommend you to use the OOTB "List update" activity.

Please see documentation:
How to use workflow data
Targeting activities

If you still need Javascript code to do the same for another reason, you can use the JSAPI nms.recipient.RegisterGroup function.
Please refer to the  JSAPI.chm documentation (restricted to license) for details.

Regards
J-Serge

View solution in original post

maurizio_coro
Level 3
Level 3

Thanks,

I've tried with the OOTB but I was unable to set the group name dynamically. I'll have a look to the documentation JSAPI

Jean-Serge_Biro
Community Advisor
Community Advisor

Hi Maurizio,

Please select the 2nd radio button then you can put your variables for the list name:

1508409_pastedImage_0.png

Regards
JS

maurizio_coro
Level 3
Level 3

Hi Jean-Serge

thanks, now my issue is how to populate the instance.vars

In my WF I've loaded an external FTP file with account_id and list_ids and with list update I've to store the recipients in the proper list. So I need to match the list_ids from the external file, with the actual ids of the already created lists.

My question is: how to put the id field in the instance.vars?

thanks

Jean-Serge_Biro
Community Advisor
Community Advisor

Please may you describe the file structure in details and tell if you can have other structure. Depending on the file structure, the treatment is different.

For instance, if the structure is:
account_id     list_ids
recipient1     list1,list2,list3

recipient2     list1,list5

the solution is probably to do it in JS with a foreach loop and splitting list_ids in a JS array with split function then call the nms.recipient.RegisterGroup

The List update activity is intended to update one List (group in case of recipient) at a time. And doing a standard loop in the workflow is not convenient. The List update is useful for mass-update (as in SQL).

But perhaps someone else could suggest another approach for doing a mass-update with such file structure.

If you have many files, each file regarding a list, the file containing the recipient id list, then I consider than using Collector files and loop for List update activity is more adapted.

Well, hope this could help.

Regards
JS

maurizio_coro
Level 3
Level 3

Hi,

that's exactly my initial structure, however after an enrichment and a deduplication activity now that's what I got:

userId, list name, list id

maybe I can now use the UpdateList activity but, again, I don't know how to get the proper name.

That's the schema:

1508418_pastedImage_0.png

So I need to put 8000037 user in the list called Mobile Phones_SA, etc.

How to get the "Mobile Phones_SA" name via the instance.vars?

I know it's a dumb question, but it's my first time...

in the meanwhile I'm trying to reach the scope via a for each: I successful listed the data, now all I need is the js code to update dynamically the lists...

Jean-Serge_Biro
Community Advisor
Community Advisor

so you can manage your goal by using the Update activity directly, with this enriched targetData result set