When a template is saved, the workflow "Campaign Copy" is executed.
This workflow has many steps, some of which execute method called CopymanyToManyObjects on business service "Copy Campaign program".
If you add code to PreInvokeMethod for this busservice , and you examine what is in the Inputs property set, you will see that 2 of the properties are :
Source Id which has the Id of the original campaign
Destination Id which has the Id of the campaign template that is created.
Once you have captured the Ids, you may add code to NewRecord event for "Campaign Template" buscomp ,and in the code you find the original campaign ( using the Id you saved ), get the extra fields, and update those extra custom fields in the Campaign Template.
Sample Script:
Added code to PreInvokeMethod event for "Copy Campaign program" busservice and capture the Inputs :
if ( MethodName == "CopyManyToManyObjects")
{
myFile = Clib.fopen("c:\\PREINV_" + MethodName +".txt","at");
Clib.fputs(" --- inputs -----\n\n", myFile);
var j = getInfo(Inputs, 0, 0);
// Clib.fputs(" --- outputs -----\n\n", myFile);
// j = getInfo(Outputs,0,0);
Clib.fclose(myFile);
}
function getInfo (Inp,level,child)
{
var s = "";
var i=0;
var j=0;
var cr = "\n";
s = "LEVEL : " + level + cr ;
s = s + "Child : " + child + cr ;
s = s + "Type = " + Inp.GetType + cr ;
s = s + "Value = " + Inp.GetValue + cr ;
s = s + "--------- Properties -----------------------------" + cr ;
var prop = Inp.GetFirstProperty();
while (prop != "")
{
s = s + prop + " : " + Inp.GetProperty(prop) + cr;
prop = Inp.GetNextProperty() ;
}
s = s + "---------------------------------------------------" + cr;
s = s + "Num of Children : " + Inp.GetChildCount() + cr;
Clib.fputs(s, myFile);
if (Inp.GetChildCount > 0)
for (i = 1; i<>
j = getInfo (Inp.GetChild(i-1), level+1 ,i);
}
The output file looks like :
--- inputs -----
LEVEL : 0
Child : 0
Type = Native function
Value = Native function
--------- Properties -----------------------------
Child BusComp : Parent Offer
Destination Id : 1-2O7CL
Destination BusComp : Campaign Template
Return Message :
Source Primary Field : Primary Offer Id
Destination Primary Field : Primary Offer Id
Source Id : 1-26R3X
Source BusObject : Campaign
Destination BusObject : Campaign Template
Source BusComp : Campaign
No comments:
Post a Comment