Example of JS nms.subscription.RecipientSubscribe()

floriancourgey

29-11-2018

Hi,

I couldn't find any working example of the following method:

XML confirmationIds = RecipientSubscribe (      XML          recipientList,      XML          serviceList,      Boolean      subscribe,      XML          sendConfirmation )

Could you please show how it works?

I tried, without the success, the following:

var serviceXml = {service: {_key: "name", name: 'myServiceInternalName'}};

var recipientXml = {recipient: {_key: "email", email: 'my-recipient@yopmail.com'}};

var sendConfirmationXml = {sendConfirmation:{sendConfirmation:'true'}}; // what to use here???

var subscribe = true;

var confirmationIds = nms.subscription.RecipientSubscribe (

    recipientXml,

    serviceXml,

    subscribe,

    sendConfirmationXml

);

logInfo(confirmationIds);

Thank you

Florian

Accepted Solutions (1)

Accepted Solutions (1)

wodnicki

MVP

07-01-2019

Hi,

Use this, apologies for the xml:

  nms.subscription.RecipientSubscribe (

    <choiceList selectAll="false">

        <key value="snarayen@adobe.com"/>

        <where>

            <condition expr="@email = 'snarayen@adobe.com'"/>

        </where>

    </choiceList>,

    <entityList selectAll="false">

        <key value="ceoTips"/>

        <where>

            <condition expr="@name = 'ceoTips'"/>

        </where>

    </entityList>,

    true,

    <empty>false</empty>

  );

You have access to the source code?

Thanks,

-Jon

Answers (5)

Answers (5)

wodnicki

MVP

04-01-2019

Hi,

That param can be left empty. If you want to send confirmations, use nms.subscription.SendConfirmation().

Recipient and services forms both stub out that param and instead send a 2nd call to that action.

Thanks,

-Jon

floriancourgey

05-03-2019

Hi wodnicki,

The issue was that the subscription was not created. There was no error raised, but nothing happened.

It turned out using the @name of the service doesn't work. We had to use the @id. So first we convert the service name to a service id, then we use your XML.

This is what we ended up doing:

var recipientEmail = "henry.gallagher@yopmail.com";

var serviceName = "ceoTips";

var subscribe = true;

var sendConfirmation = true;

// get service id

var query = NLWS.xtkQueryDef.create({queryDef: {

  schema: "nms:service", operation: "get",

    select: { node: {expr: "@id"} },

    where: { condition: {expr: "@name='"+serviceName+"'"} },

}});

var serviceId = query.ExecuteQuery().$id;

// recipient query

var recipientList = {choiceList:{

  where: { condition: { expr: "@email = '"+recipientEmail+"'" } },

}}

// service query

var serviceList = entityList = {entityList:{

  key:{ value: serviceId }

}}

// call

var confirmationIds = nms.subscription.RecipientSubscribe (  

  recipientList, serviceList,

  subscribe, {empty: sendConfirmation}

);

logInfo('confirmationIds', confirmationIds); // DOMElement

logInfo('confirmationIds', confirmationIds.toString()); // 1:DM11|13605

logInfo('confirmationIds', confirmationIds.toXMLString(true)); // <elemConfirmationIds>1:DM11|13605</elemConfirmationIds>

Which seems overkill just to programmatically subscribe a recipient with the confirmation email... But it is needed in our case for a custom SOAP call.

Thank you

Florian

wodnicki

MVP

22-01-2019

Oh I thought you meant the source code, cpp files. Most of those objects can be exported out of the instance per normal, some of them like non-specific db functions can only be read from the install dirs. What was the issue with the call I pasted?

floriancourgey

22-01-2019

Thanks, it's still not working but I'll have a second look

Source code can be downloaded on the support platform, from your Download Center > Build Neolane v6.1 nlserver6-8864-x86_64_rh7.rpm (8864)

adobe-campaign-rpm-file-download-center.jpg

Which contains some .xml and .js files, i.e. Find files with Notepad++:

adobe-campaign-find-source-code.jpg

Source: Access to Adobe Campaign Source Code

floriancourgey

07-01-2019

Hi Jon,

I tried to leave the last argument empty, but it doesn't work:

nms.subscription.RecipientSubscribe(recipientList, serviceList, subscribe);

It gives the error

01/07/2019 2:12:25 PM js SCR-160012 JavaScript: error while evaluating script 'WKF407/js'.

01/07/2019 2:12:25 PM js Missing argument 'sendConfirmation' for method 'RecipientSubscribe' of schema 'nms:subscription'.

I also tried the following, which doesn't work:

var sendConfirmation = ''; // cannot convert the value to an XML document

var sendConfirmation = null; // cannot convert the value to an XML document

var sendConfirmation = {}; // does nothing

var sendConfirmation = {sendConfirmation:{$:true}}; // puts the workflow in a hanging state (Automatically resuming workflow (number of consecutive times: 1))

Finally, I looked for any reference of "RecipientSubscribe(" in the AC7-8864 source code, but I couldn't find any.

You got any idea?

Thanks