locked
Copy campaign response plug-in. Dialog box 'Quick Create: campaign response' RRS feed

  • Question

  • Hi,

     

    I am trying to find out SDK message which will handle ‘Copy campaign response to another campaign’ action. For some reason some of my custom fields are not copy across and I would like to do it by plug-in. I been trying to use Pre/Child/Synch and Pre/Parent/Synch, but context doesn’t include activityid of original campaign response.

     

    Any Idea how to do it or why copy campaign response do not copy all fields?


    Mariusz
    Thursday, May 6, 2010 5:29 AM

Answers

  • It looks like this can be done by JavaScript onLoad when crmForm.FormType == 5

    I think this belongs to campaign accelerators.


    if(crmForm.FormType == 5)
    {
       //remove entire rows
       var elem = crmForm.all.ownerid_c;
       if( elem != null ) elem.parentElement.style.display = "none";
       elem = crmForm.all.new_originating_cr_c;
       if( elem != null ) elem.parentElement.style.display = "none";
       elem = crmForm.all.subject_c;
       if( elem != null ) elem.parentElement.style.display = "none";
       elem = crmForm.all.new_replicated_cr_c;
       if( elem != null ) elem.parentElement.style.display = "none";
     


       var theOpener = window.dialogArguments;

       if ((theOpener != null) && (theOpener.parent != null) &&
    (theOpener.parent.document != null) && (theOpener.parent.document.crmForm != null))
      {
           var parentForm = theOpener.parent.document.crmForm;
           if(parentForm.ObjectTypeName == "campaignresponse")
           {
                var crid = parentForm.ObjectId;
                crid = crid.replace("{","");
                crid = crid.replace("}","");
                crmForm.all.new_originating_cr.DataValue = crid;
                crmForm.all.subject.DataValue = parentForm.all.subject.DataValue;

                crmForm.all.subject.Disabled = true;
                crmForm.all.subject.ForceSubmit = true;
                crmForm.all.new_originating_cr.Disabled = true;
                crmForm.all.new_originating_cr.ForceSubmit = true;
                crmForm.all.new_replicated_cr.Disabled = true;
                crmForm.all.new_replicated_cr.ForceSubmit = true;
           }
       }
    }
    else
    {
      //CRM form - hide originating CR field
      crmForm.all.new_originating_cr_c.style.display = "none";
      crmForm.all.new_originating_cr_d.style.display = "none";
      crmForm.all.new_replicated_cr_c.style.display = "none";
      crmForm.all.new_replicated_cr_d.style.display = "none";
      //crmForm.all.new_sync_c.style.display = "none";
      //crmForm.all.new_sync_d.style.display = "none"; 
    }

    And crmForm.all.new_originating_cr.DataValue is the answer.

     


    Mariusz
    Friday, May 7, 2010 12:02 AM

All replies

  • Hi,

    If you are referring to Actions-->Copy Campaign Response.

    Than the values for the custom fields should get copied ideally.

    However to retrieve the activityid of the original campaign response, you could follow these steps.

    Create a new custom attribute of nvarchar type and populate that field's value using JavaScript in form onload

    crmForm.all.new_customfield.DataValue=crmForm.ObjectId;

    And register your plugin in Post Create event of Campaign Response,

    there you can get the value for the above field in InputParameter's Target property.

     

    Regards,

    Nishant Rana


    http://nishantrana.wordpress.com
    Thursday, May 6, 2010 7:34 AM
  • Hi Rana,

    Your workaround should work, but I have thousands of existing campaign responses where new_customfield field will be blank, so CRM user has to open campaign responses then Save and then Copy.

    Is there any SDK message which recognise action of Copy campaign responses? I know that campaign have this - context.ParentContext.MessageName != "Copy".

     


    Mariusz
    Thursday, May 6, 2010 10:03 PM
  • I have checked Actions-->Copy Campaign Response and it looks like all fields are copied across. I am using ‘Copy campaign response to another campaign’ (button) and that action do not copy custom fields (other than Boolean) across, so workaround with new_customfield is not working as well.


    Mariusz
    Thursday, May 6, 2010 11:17 PM
  • It looks like this can be done by JavaScript onLoad when crmForm.FormType == 5

    I think this belongs to campaign accelerators.


    if(crmForm.FormType == 5)
    {
       //remove entire rows
       var elem = crmForm.all.ownerid_c;
       if( elem != null ) elem.parentElement.style.display = "none";
       elem = crmForm.all.new_originating_cr_c;
       if( elem != null ) elem.parentElement.style.display = "none";
       elem = crmForm.all.subject_c;
       if( elem != null ) elem.parentElement.style.display = "none";
       elem = crmForm.all.new_replicated_cr_c;
       if( elem != null ) elem.parentElement.style.display = "none";
     


       var theOpener = window.dialogArguments;

       if ((theOpener != null) && (theOpener.parent != null) &&
    (theOpener.parent.document != null) && (theOpener.parent.document.crmForm != null))
      {
           var parentForm = theOpener.parent.document.crmForm;
           if(parentForm.ObjectTypeName == "campaignresponse")
           {
                var crid = parentForm.ObjectId;
                crid = crid.replace("{","");
                crid = crid.replace("}","");
                crmForm.all.new_originating_cr.DataValue = crid;
                crmForm.all.subject.DataValue = parentForm.all.subject.DataValue;

                crmForm.all.subject.Disabled = true;
                crmForm.all.subject.ForceSubmit = true;
                crmForm.all.new_originating_cr.Disabled = true;
                crmForm.all.new_originating_cr.ForceSubmit = true;
                crmForm.all.new_replicated_cr.Disabled = true;
                crmForm.all.new_replicated_cr.ForceSubmit = true;
           }
       }
    }
    else
    {
      //CRM form - hide originating CR field
      crmForm.all.new_originating_cr_c.style.display = "none";
      crmForm.all.new_originating_cr_d.style.display = "none";
      crmForm.all.new_replicated_cr_c.style.display = "none";
      crmForm.all.new_replicated_cr_d.style.display = "none";
      //crmForm.all.new_sync_c.style.display = "none";
      //crmForm.all.new_sync_d.style.display = "none"; 
    }

    And crmForm.all.new_originating_cr.DataValue is the answer.

     


    Mariusz
    Friday, May 7, 2010 12:02 AM