Expand my Community achievements bar.

RecipientSubscribe - Multiple Recipients to Subscribe to a Service

Avatar

Level 5

Hi All,

 

I have a requirement where I need

1. Multiple recipients to subscribe to more than one service

 

I am trying to use the RecipientSubscribe to do the same, but unable to create the 

XML          recipient 

parameter. Can somebody please help me on the same

 

The set of recipients are coming as part of a query in workflow, can we use any Workflow activity other than JS to achieve this ? In Subscription services activity can we map 2 services at a time ?

 

Regards,

DG 

 

 

 

 

6 Replies

Avatar

Community Advisor

Hello @dipendu_g 

 

You can do something like this:

  var recipient = {recipient: {_key: "email", email: "john.smith@example.com"}} // identify the recipient
nms.subscription.Subscribe("SVC1", recipient, false) //subscribe to service 1
nms.subscription.Subscribe("SVC2", recipient, false) //subscribe to service 2
nms.subscription.Subscribe("SVC3", recipient, false) //subscribe to service 3
nms.subscription.Subscribe("SVC4", recipient, false) //subscribe to service 4

 

more details on the function is here: https://experienceleague.adobe.com/developer/campaign-api/api/sm-subscription-Subscribe.html


     Manoj
     Find me on LinkedIn

Avatar

Level 5

Hi @_Manoj_Kumar_ ,

 

I am looking for multiple recipients to subscribe at one Service.

Can't we use the RecipientSubscribe  API ?

 

Regards,

DG

 

Avatar

Community Advisor

Try using this.

 

 

 nms.subscription.RecipientSubscribe ( 
    <choiceList selectAll="false">
        <key value={rcpId}/>
        <where>
            <condition expr={"@id = '"+rcpId+"'"}/> // condition to filter the recipient
        </where>
    </choiceList>,
    <entityList selectAll="false">
        <key value="12732"/>
        <where>
            <condition expr="@id = '12732'"/>   // condition to get the service
        </where>
    </entityList>, 
    true,
    <empty>false</empty>
  );

Note: Don't use the bulk update the recipients via APIs. Always chunk them in small payloads.

 


     Manoj
     Find me on LinkedIn

Avatar

Level 5

Hi @_Manoj_Kumar_ ,

 

Since we are using the rcpId in the where clause, would it restrict to just one recipient at a time. Cany we have a set of recipients in choiceList

 

 

Regards,

DG

Avatar

Community Advisor

Hello @dipendu_g 

 

Yes you can hardcode the values to fix one like this.

<where>
 <condition expr="@email IN 'test@gmail.com,test2@gmail.com'"/>
 </where>

     Manoj
     Find me on LinkedIn