Expand my Community achievements bar.

We are excited to introduce our latest innovation to enhance the Adobe Campaign user experience — the Adobe Campaign v8 Web User Interface!
SOLVED

WriteCollection & nms.Subscription.Subscribe()

Avatar

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

Avatar

Correct answer by
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

Avatar

Correct answer by
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)

};