Here is a handy script to opt in/out recipient from all subscription services within Adobe Campaign through javascript activity.
loadLibrary("/nl/core/shared/nl.js");
NL.require("/nl/core/shared/xtk.js");
/***********************************************************************
Purpose: Opts the recipient in to all services
Input: recipient in xml form eg <recipient @id="123"/>
Returns: nothing
**********************************************************************/
var optInAll = function(recipient){
var query = xtk.queryDef.create(<queryDef schema='nms:service' operation='select'>
<select>
<node expr='@name'/>
</select>
<where>
<condition expr = "[folder/@id]<> 0 " />
<condition expr = "[@id]<>0" />
</where>
</queryDef>);
var services = query.ExecuteQuery();
for each(var service in services){
nms.subscription.Subscribe(service.@name, recipient, false);
}
}
/***********************************************************************
Purpose: Opts the recipient out of all services
Input: recipient in xml form eg <recipient @id="123"/>
Returns: nothing
**********************************************************************/
var optOutAll = function(recipient){
var query = xtk.queryDef.create(<queryDef schema='nms:service' operation='select'>
<select>
<node expr='@name'/>
</select>
<where>
<condition expr = "[folder/@id]<> 0 " />
<condition expr = "[@id]<>0" />
</where>
</queryDef>);
var services = query.ExecuteQuery();
for each(var service in services){
nms.subscription.Unsubscribe(service.@name, recipient);
}
}
/***********************************************************************
Purpose: Opts the recipient in to particular services
Input: recipient in xml form eg <recipient @id="123"/>
Returns: nothing
***********************************************************************/
var optinService = function(recipient, serviceName){
nms.subscription.Subscribe(serviceName, recipient, false);
}
/**********************************************************************
Purpose: Opts the recipient out of particular services
Input: recipient in xml form eg <recipient @id="123"/>
Returns: nothing
**********************************************************************/
var optoutService = function(recipient, serviceName){
nms.subscription.Unsubscribe(serviceName, recipient);
}
###
(Visited 798 times, 1 visits today)