As you aware, we don't have control on computed deliveries hence I am managing seeds through JS Script. The requirement I have is: There are two folders 'ABC-Seeds' and 'XYZ-Seeds', I need to target to complete folder of 'ABC-seeds' and 2 ids of 'XYZ-Seeds' folder, Email IDs are: 'email1' and 'email2'. The JavaScript I am using is as follows:
// query the database to find the winner (best open rate)
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]"/>
<node expr="[scheduling/@contactDate]"/>
<node expr="[output/seedList/where/condition/@expr]"/>
</select>
<where>
<condition expr={"@FCP=0 and @internalName = 'Em123' and @isModel=0"}/>
</where>
<orderBy>
<node expr="[indicators/@estimatedRecipientOpenRatio]" 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 'winner' to the delivery label
delivery.label = winner.@label + " Test"
delivery.operation_id = winner.@["operation-id"]
delivery.workflow_id = winner.@["workflow-id"]
delivery.output.seedList.humanCond = "Query: folder equal to ABC-Seeds or (folder equal to XYZ-Seeds and email of recipient is included in 'email1,email2')"
delivery.output.seedList.where.displayFilter = "folder equal to ABC-Seeds or (folder equal to XYZ-Seeds and email of recipient is included in 'email1,email2')"
delivery.output.seedList.where.condition.expr= ("[@folder-id] = 9787930 or [@folder-id] = 882531 and [custom_nms_recipient/@email] IN ('email2' , 'email2')")
// save the delivery in database
delivery.save()
// store the new delivery Id in event variables
vars.deliveryId = delivery.id
// Print Log Details
logInfo(vars.deliveryId)
logInfo(delivery.label)
logInfo(winner.output.seedList.where.condition.@expr)
The challanges here I am facing is:
1. The Filtering Condition is taking up as foriegn key of folder id(Below is the screenshot for reference)
2. Everytime it is appending the condition and not replacing the condition with the new computed delivery in Filerting Condition
Please have a look on this and Prompt response will be appreciated.
Solved! Go to Solution.
Hi mustufam59678037,
I think that the conditions were not in the winner delivery.
The conditions must be there in the original delivery (winner delivery) when you create the duplicated delivery:
- If yes, the JS code will modifying the values of the duplicated delivery conditions so the provided code will be good.
- If not, the JS code need to be modified in order to create the conditions in the duplicated delivery and not just modifying them.
Many thanks,
Geoffrey.
wodnickiCampaign Classic - Questions Adobe Campaign Classic
Hi Team,
This is a bit urgent , please help.
Thanks in advance.
Views
Replies
Total Likes
Hi Team,
Any udpate on this, please?
Views
Replies
Total Likes
Adobe Campaign Standard Adobe Campaign Classic @pablo.rosero @Vipul Raghav
Hi Team,
Can anyone from you look into this, its been more than 2 weeks.
Please reply!
Views
Replies
Total Likes
Hi, can anyone give Mustufa a hand with this query?
Views
Replies
Total Likes
Hello mustufam59678037,
If I have this conditions on my original delivery (winner delivery in your case):
I can replace the conditions with this JS code:
delivery.output.seedList.where[0].condition[0].boolOperator = 'AND';
delivery.output.seedList.where[0].condition[0].expr = "[custom_nms_recipient/@email] IN ('xyz123@email.com', 'xyz123@ymail.com')";
delivery.output.seedList.where[0].condition[0].condition[0].boolOperator = 'AND';
delivery.output.seedList.where[0].condition[0].condition[0].condition[0].boolOperator = 'OR';
delivery.output.seedList.where[0].condition[0].condition[0].condition[0].expr = '[folder/@id]=9787930';
delivery.output.seedList.where[0].condition[0].condition[0].condition[1].expr = '[folder/@id]=882531';
And my duplicated delivery contains the new conditions:
I hope that helps.
Thanks and Regards,
Geoffrey.
Hi Geoffrey
geoffreyl24045476, Thank you for your response on this.
I tried the above provided Script, however getting an error saying delivery.output.seedList.where[0] is undefined, below is the screenshot for reference getting in Display Logs.
Here is the complete code I am trying with:
// query the database to find the winner (best open rate)
var winner = xtk.queryDef.create(
<queryDef schema="nms:delivery" operation="select">
<select>
<node expr="@id"/>
<node expr="@label"/>
<node expr="[@operation-id]"/>
<node expr="[@workflow-id]"/>
<node expr="[scheduling/@contactDate]"/>
<node expr="[output/seedList/where/condition/@expr]"/>
</select>
<where>
<condition expr={"@FCP=0 and @internalName = 'Em123' and @isModel=0"}/>
</where>
<orderBy>
<node expr="[indicators/@estimatedRecipientOpenRatio]" 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 'winner' to the delivery label
delivery.label = winner.@label + " Test"
delivery.operation_id = winner.@["operation-id"]
delivery.workflow_id = winner.@["workflow-id"]
delivery.output.seedList.humanCond = "Query: folder equal to ABC-Seeds or (folder equal to XYZ-Seeds and email of recipient is included in 'email1,email2')"
delivery.output.seedList.where.displayFilter = "folder equal to ABC-Seeds or (folder equal to XYZ-Seeds and email of recipient is included in 'email1,email2')"
delivery.output.seedList.where[0].condition[0].boolOperator = 'AND';
delivery.output.seedList.where[0].condition[0].expr = "[custom_nms_recipient/@email] IN ('xyz123@email.com', 'xyz123@ymail.com')";
delivery.output.seedList.where[0].condition[0].condition[0].boolOperator = 'AND';
delivery.output.seedList.where[0].condition[0].condition[0].condition[0].boolOperator = 'OR';
delivery.output.seedList.where[0].condition[0].condition[0].condition[0].expr = '[folder/@id]=9787930';
delivery.output.seedList.where[0].condition[0].condition[0].condition[1].expr = '[folder/@id]=882531';
// save the delivery in database
delivery.save()
// store the new delivery Id in event variables
vars.deliveryId = delivery.id
// Print Log Details@
logInfo(vars.deliveryId)
logInfo(delivery.label)
logInfo(winner.output.seedList.where.condition.@expr)
Regards,
Mustufa
Views
Replies
Total Likes
Hi mustufam59678037,
Indeed, please remove the "[0]" from each "where", that should be good without.
Thanks,
Geoffrey.
Thank you for your quick response.
Tested the condition by removing "[0]" from "where" as well as from "condition", however getting an error saying index out of range.
Views
Replies
Total Likes
Hi mustufam59678037,
I think that the conditions were not in the winner delivery.
The conditions must be there in the original delivery (winner delivery) when you create the duplicated delivery:
- If yes, the JS code will modifying the values of the duplicated delivery conditions so the provided code will be good.
- If not, the JS code need to be modified in order to create the conditions in the duplicated delivery and not just modifying them.
Many thanks,
Geoffrey.
Views
Likes
Replies