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

WriteCollection & nms.Subscription.Subscribe()

davidl14970702
Level 5
Level 5

I have an API pulling back the data. I have configured the writeCollection(). But was wondering how I can also subscribe these users to the correct service.

I couldn't get the subscribe() method to work on the collection. I tried to use RecipientSubscribe() but I kept getting a error with the third argument. Is there somthing I am missing? I want to write recipients to the AC DB and also subscribe them to the service.

//loop to write to AC DB 

var emails = emailObject;

for (a in emails.Results) {

c += "<recipient _key='email, [folder-id]' email='" + emails.Results[a].EmailAddress + "' folder-id='1187' lastName='testing' _key='@email'/>";//original

};

var startCollection = "<recipient-collection xtkschema='nms:subscription' operation='insertOrUpdate'>";

var endCollection = "</recipient-collection>"

var recp = startCollection + c + endCollection;

xtk.session.WriteCollection(recp);

1 Accepted Solution
davidl14970702
Correct answer by
Level 5
Level 5

I have found a nested subscribe function is easier to use than the write collection function Because you can create the recipient record and subscribe them to a service in one shot.

var service = "serv1_internalName";

var create = true;

for (a in emails.Results) {

rcp += "<recipient _key='@email' email='" + emails.Results[a].EmailAddress +"' firstName='Testing2'/>";

nms.subscription.Subscribe(service, rcp, create)

};

View solution in original post

1 Reply
davidl14970702
Correct answer by
Level 5
Level 5

I have found a nested subscribe function is easier to use than the write collection function Because you can create the recipient record and subscribe them to a service in one shot.

var service = "serv1_internalName";

var create = true;

for (a in emails.Results) {

rcp += "<recipient _key='@email' email='" + emails.Results[a].EmailAddress +"' firstName='Testing2'/>";

nms.subscription.Subscribe(service, rcp, create)

};

View solution in original post