Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to create and trigger a delivery using js activity webapp / workflow CreateFromModel, PrepareFromId

Avatar

Employee Advisor

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);

 

 

 

 

David__Garcia_0-1639051358726.png

 

David__Garcia_1-1639060090121.png

 

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>);

 

 

David__Garcia_0-1639064307863.png

 

 

Thanks

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

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.

David__Garcia_1-1639065370868.png

David__Garcia_2-1639065436689.pngDavid__Garcia_3-1639065465808.png

 

 

View solution in original post

0 Replies

Avatar

Community Advisor

Hello @David__Garcia 

 

A solution is posted here for personalized HTML and submit delivery method.

https://experienceleaguecommunities.adobe.com/t5/adobe-campaign-standard/how-to-send-an-email-throug...

 

Another way to do is by creating a workflow with external signal and then passing the dynamic variables to WF by postevent menthod.

 

Avatar

Employee Advisor

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?

David__Garcia_0-1639064472708.png

 

Avatar

Employee Advisor

Thanks Manoj,

It was all down to the bloody template which had the wrong target mapping set. both scripts actually work.

Avatar

Correct answer by
Employee Advisor

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.

David__Garcia_1-1639065370868.png

David__Garcia_2-1639065436689.pngDavid__Garcia_3-1639065465808.png