WriteCollection & nms.Subscription.Subscribe() | Community
Skip to main content
davidl14970702
Level 4
July 14, 2018
Solved

WriteCollection & nms.Subscription.Subscribe()

  • July 14, 2018
  • 1 reply
  • 2209 views

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

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 davidl14970702

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)

};

1 reply

davidl14970702
davidl14970702AuthorAccepted solution
Level 4
July 23, 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)

};