Hi All,
I am working on a preference centre with the aim of notifying users on profile changes so that these can then be approved or cancelled, normally, I would trigger a command from the webapp to start a workflow and submit a few variables to personalize a delivery and execute it, however, I want to test out an alternative way of triggering the notification but I am short in time to go deep into testing and finding out how it works.
How do you personalize, and execute a delivery on the fly using js activity? my goal is to execute it from the webapp, (under other circumstances if the client had a message centre, I would construct and trigger a real time event to message centre, but the client does not have this)
Here is what I have so far, but to put it sumply, I want to have a delivery template with some html and variables in it, then trigger the delivery from within the webapp.
var delivery = nms.delivery.create();
delivery.label="Delivery Test"
delivery.scheduling.validationMode = "automatic"
delivery.scheduling.delayed = 0
delivery.save()
vars.deliveryId = delivery.id
Update 1
I have the following script, but I am facing an issue
var recipientId = 13241267;
var template = "changesNotification";
var x = <delivery>
<targets>
<deliveryTarget>
<targetPart exclusion='false' ignoreDeleteStatus='false'>
<where>
<condition expr={'@id=' + recipientId}/>
</where>
</targetPart>
</deliveryTarget>
</targets>
</delivery>;
var y = nms.delivery.CreateFromModel(template, x);
var z = nms.delivery.create(y);
z.scheduling.delayed = 0;
z.scheduling.validationMode = "auto";
z.save();
nms.delivery.PrepareFromId(z.id);
Update 2
I've used the SubmitDelivery method and I still get the same error
var deliveryId = nms.delivery.SubmitDelivery("changesNotification",
<delivery>
<targets>
<deliveryTarget>
<targetPart exclusion='false' ignoreDeleteStatus='false'>
<where>
<condition expr="[@id] = 13246096"/>
</where>
</targetPart>
</deliveryTarget>
</targets>
</delivery>);
Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
Update 3
Both scripts actually work, after double checking the configuration of my template, the target mapping had been set to nms:subscription rather than nms:recipient which is what the error code was pointing to, I can now sleep in peace.
Views
Replies
Total Likes
Views
Replies
Total Likes
Hello @david--garcia
A solution is posted here for personalized HTML and submit delivery method.
Another way to do is by creating a workflow with external signal and then passing the dynamic variables to WF by postevent menthod.
Hey Manoj,
I've already tried and I get the same error, please see update 2, I am wondering why the audit log states attribute id unknown and to check the definition of the nms:subscription schema, could you please test both scripts on your side and let me know if you get the same error?
Views
Replies
Total Likes
Trying chaging the condition to
<condition expr="@id = 13246096"/>
Thanks Manoj,
It was all down to the bloody template which had the wrong target mapping set. both scripts actually work.
Views
Replies
Total Likes
Update 3
Both scripts actually work, after double checking the configuration of my template, the target mapping had been set to nms:subscription rather than nms:recipient which is what the error code was pointing to, I can now sleep in peace.
Views
Replies
Total Likes