Passing deliveries dynamically from script to continuous delivery
I am using the Javascript activity with below script and in the subsequent continuous delivery activity I am setting the activity.scenario_id with delivery created in this script and for recipients in continuous delivery, I am checking the option "specified by the inbound events". But the real issue is the delivery is being created and it's in being edited state, not getting executed can you please help me out on this issue.

Javascript activity code:
var winner = xtk.queryDef.create(
<queryDef schema="nms:delivery" operation="get">
<select>
<node expr="@id"/>
<node expr="@label"/>
<node expr="[@operation-id]"/>
<node expr="[@workflow-id]"/>
</select>
<where>
<condition expr={"@FCP=0 and @internalName in ('DTB100919070906','DTA100919070906')"}/>
</where>
<orderBy>
<node expr="[indicators/@estimatedRecipientOpenRatio]" sortDesc="true"/>
<node expr="[indicators/@recipientClickRatio]" sortDesc="true"/>
</orderBy>
</queryDef>).ExecuteQuery();
// 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.@id);
// append 'final' to the delivery label
delivery.label = winner.@label;
logInfo(delivery.label);
// 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 = winner.@["operation-id"];
delivery.workflow_id = winner.@["workflow-id"];
delivery.internalName = "DMF" + formatDate(new Date(), "%2D%2M%2Y%2H%2m%2s");
// 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";
delivery.validation.useBudgetValidation =false;
delivery.validation.useContentValidation = false;
delivery.validation.useExtractionValidation = false;
delivery.validation.useTargetValidation = false;
delivery.validation.useFCPValidation = false;
delivery.scheduling.delayed = 0;
// save the delivery in database
delivery.save();
vars.deliveryId = delivery.id;
Continuous delivery activity script:
activity.scenario_id = vars.deliveryId;
vars.recipientsL