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

WriteCollection & nms.Subscription.Subscribe()

Avatar

Avatar
Validate 10
Level 4
davidl14970702
Level 4

Likes

30 likes

Total Posts

93 posts

Correct Reply

13 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Validate 10
Level 4
davidl14970702
Level 4

Likes

30 likes

Total Posts

93 posts

Correct Reply

13 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 1
View profile
davidl14970702
Level 4

14-07-2018

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);

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 10
Level 4
davidl14970702
Level 4

Likes

30 likes

Total Posts

93 posts

Correct Reply

13 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Validate 10
Level 4
davidl14970702
Level 4

Likes

30 likes

Total Posts

93 posts

Correct Reply

13 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 1
View profile
davidl14970702
Level 4

23-07-2018

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)

};

Answers (0)