Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards
SOLVED

JavaScript API generated delivery does not have access to targetData

Avatar

Level 2

Hello,

 

We are performing A/B testing on a pair of deliveries and trying to generate a winner delivery for the remaining population after a wait period for feedback. We have followed along with the solution in other Experience League posts, and can generate the delivery within the JS code activity as a copy of the winning test delivery via Duplicate(), post winner decision.

 

The issue that we are encountering is that we happen to use targetData as a source of a number of Target Mappings into broadLogRCP and substitutions into our emails. We haven't had issues with this in the few years that we have been using Adobe Campaign, but this is the first time that we have tried any deliveries from code. All others have explicitly been defined in Delivery activities. In this case, none of the targetData is recognized (we can see it in the transitions) so our broadLogRCP records are mostly empty, aside from Recipient and Delivery references, and our emails are produced with missing content.

 

Our original attempts followed a design pattern of defining the delivery in the code and then passing that into a Delivery activity with the Delivery option set to "Delivery defined in the transition".

 

We produce the delivery object in the code:

// logic prior to this point determines the winning A/B delivery, stored in 'winner'
// winner[0] is delivery id
// winner[1] is the delivery label
// winner[2] is the count of email clicks for the winning delivery

// create a new delivery object and initialize it by doing a copy of
// the winner delivery
var delivery = nms.delivery.create()

delivery.Duplicate("nms:delivery|" + winner[0]);  
logInfo("Delivery duplicated from the winner.");
 
// append 'final' to the delivery label
delivery.label = winner[1] + " final" + formatDate(new Date(), "%2D%2M%2Y");
logInfo("Delivery label set: " + delivery.label);

//delivery.deliveryCode = winner.@deliveryCode;
//logInfo("Delivery code inherited: " + delivery.deliveryCode);
 
// link the delivery to the operation to make sure it will be displayed in
// the campaign dashboard. This attribute needs to be set manually here since
// the Duplicate() method has reset it to its default value => 0
delivery.operation_id = instance.operation_id;
delivery.workflow_id = instance.id;
logInfo("Delivery operation_id and workflow_id set.");
 
// adjust some delivery parameters to make it compatible with the
// "Prepare and start" option selected in the Delivery tab of this activity
delivery.scheduling.validationMode = "auto";  
// tried 'auto' and 'manual', same behavior
logInfo("delivery.scheduling.validationMode: " + delivery.scheduling.validationMode);
delivery.scheduling.delayed = 0
delivery.validation.useBudgetValidation = false;
delivery.validation.useContentValidation = false;
delivery.validation.useExtractionValidation = false;
delivery.validation.useTargetValidation = false;
delivery.validation.useFCPValidation = false; 
logInfo("Delivery parameters set.");

// save the delivery in database
delivery.save()
logInfo("Delivery saved.");
logInfo("delivery.id: " + delivery.id);

// store the new delivery Id in event variables
vars.deliveryId = delivery.id
logInfo("winner delivery configured");

 

Attempts to fire off PrepareAndStart(), or Prepare() and Play(), to launch the delivery in the script itself, fails with errors:

/*
04/24/2025 4:11:43 PM	US_ALL_GW23Apr25T1 (6162280) wins with 5 email clicks vs the loser's 2
04/24/2025 4:11:44 PM	Delivery duplicated from the winner.
04/24/2025 4:11:44 PM	Delivery label set: US_ALL_GW23Apr25T1 final240425
04/24/2025 4:11:44 PM	Delivery operation_id and workflow_id set.
04/24/2025 4:11:44 PM	delivery.scheduling.validationMode: auto
04/24/2025 4:11:44 PM	Delivery parameters set.
04/24/2025 4:11:44 PM	Delivery saved.
04/24/2025 4:11:44 PM	delivery.id: 6165100
04/24/2025 4:11:44 PM	winner delivery configured
04/24/2025 4:11:44 PM	Target preparation in progress...
04/24/2025 4:11:44 PM	Waiting on replication: schema:'nms:delivery', id(s): '6165100'
04/24/2025 4:12:14 PM	Initializing delivery process...
04/24/2025 4:12:14 PM	Loading typology rules (step: javascript/preTarget)...
04/24/2025 4:12:14 PM	Applying rule 'bcc address, email regex and domain allowlist check'.
04/24/2025 4:12:14 PM	Applying rule 'OneClickUnsubscribe Interval'.
04/24/2025 4:12:15 PM	XTK-170024 The temporary 'temp:delivery552-all' schema is not defined in the current context.
04/24/2025 4:12:15 PM	XTK-170036 Unable to parse expression '@id=[temp:delivery552-all:@id]'.
04/24/2025 4:12:15 PM	SOP-330011 Error while executing the method 'PrepareTargetImpl' of service 'nms:delivery'.
04/24/2025 4:12:15 PM	SOP-330011 Error while executing the method 'PrepareTarget' of service 'nms:delivery'.
04/24/2025 4:12:15 PM	SOP-330011 Error while executing the method 'Prepare' of service 'nms:delivery'.
04/24/2025 4:12:15 PM	SCR-160012 Javascript: error while evaluating script 'pWKF4885/js266'.
*/

 

The temp table passed in from the prior activity is actually temp:extract4. We are not sure where the reference to "temp:delivery552-all" is coming from. My guess is that the same type of error is occurring when we pass it off to the Delivery activity, but it is not getting logged and it proceeds with the delivery anyhow (thus the missing targetData content).

 

Is there a way to explicitly define the targetData schema for a delivery to use via API? Or anything else that we are missing?

 

Thank you.

1 Accepted Solution

Avatar

Correct answer by
Level 4

Hi @Ryan_Bard ,

 

In star delivery, change it to third option - computed by script

 

Add this code: <%= vars.deliveryId %>

 

Save it and try executing the flow now.

 

Regards,

Sujith kumar 

View solution in original post

9 Replies

Avatar

Level 4

Hi @Ryan_Bard ,

 

Are you using an A/B delivery template? The issue is with the templateIsModel setting in the delivery. When you don't use a template, the delivery duplicates itself as a template instead of as an actual delivery. You must create an A/B template and configure the delivery properly.

 

Regards,

Sujith kumar

Avatar

Level 2

Thank you for the response, @Sujith_02kumar.

 

I do not think that we are. We have two standard email delivery templates that we send to our A/B populations, check the results after a Wait, and take the winner and Duplicate() that winner delivery. Can you point me to any documentation about setting up an explicit A/B Delivery Template, and how it differs from a standard template?

 

Thank you,

Ryan Bard

Avatar

Level 2

Note that I am referring to any documentation beyond the example A/B testing in the main documentation. What we have done does use templates, as laid out in the Configure deliveries | Adobe Campaign example. But there is nothing from a setup perspective that identifies them as A/B templates, that is only defined by using them in this scenario. The A and B deliveries are sourced from templates, not built directly in the workflow. The winner is identified by a delivery id, which is fed into the code above. 

 

One thing that I do notice is the difference in activity types. We are using this Delivery action:

Ryan_Bard_0-1745849935497.png

 

I notice that the documentation shows the use of this type:

Ryan_Bard_1-1745850039493.png

 

This is due to the original campaign that was setup by our Marketing team, as guided by the original Adobe consulting team that helped us get AC set up. Is the type of delivery action possibly the problem?

 

Thank you,

Ryan Bard

Avatar

Level 2

Sujith,

 

Yes, we did follow the same steps. I recreated it with the same delivery type used in the documentation, as well, and the issue persists.

 

You stated that "The issue is with the templateIsModel setting in the delivery. When you don't use a template, the delivery duplicates itself as a template instead of as an actual delivery. You must create an A/B template and configure the delivery properly."

 

How do I configure the delivery's templateIsModel setting? Is that just a variable on the delivery that I need to set to true?

 

The winning delivery that it is copying via the Duplicate() call is template based (both A and B emails are template driven). The example in the documentation implies that this is all that is required to produce a valid delivery?

 

Thank you,

Ryan Bard

Avatar

Level 4

@Ryan_Bard ,

 

Can you show ur workflow configuration end to end?

 

Regards,

Sujith kumar 

Avatar

Level 2

@Sujith_02kumar,

 

Sure, here it is.

Ryan_Bard_0-1745960285998.png

Ryan_Bard_1-1745960524745.png

We have one test user in this case, so we fork them to be the audience for all three emails: A, B and Winner.

 

Ryan_Bard_2-1745960728662.png

The AND-join that we use to hold off the Wait activity until both A and B completely go out, uses the center audience as the passed along data set.

 

Ryan_Bard_3-1745961000954.png

 

This is the config for our winner delivery activity:

Ryan_Bard_4-1745961109177.png

 

 

Thanks,

Ryan Bard

Avatar

Correct answer by
Level 4

Hi @Ryan_Bard ,

 

In star delivery, change it to third option - computed by script

 

Add this code: <%= vars.deliveryId %>

 

Save it and try executing the flow now.

 

Regards,

Sujith kumar 

Avatar

Level 2

That did the trick! Thank you very much for the assistance, @Sujith_02kumar . Hopefully the AB testing documentation gets updated to reflect that last part.