locked
How to set default regarding in email activity by java script RRS feed

  • Question

  • Hi,

    I created button and when click on this button, it open new email activity from the custom entity. It is working fine.  I could set default subject but I could not set default regarding.  Please find below the java code. It is displaying correct id and name on alert message but it give error when set regarding value.  Please verify the code and find solution.

    function sendmail()
    {
    var lookupData = new Array();
    var lookupItem= new Object();
    lookupItem.id = Xrm.Page.data.entity.attributes.get("new_accountid").getValue()[0].id;
    alert(Xrm.Page.data.entity.attributes.get("new_accountid").getValue()[0].id);
    lookupItem.typename = "account";
    lookupItem.name = Xrm.Page.data.entity.attributes.get("new_accountid").getValue()[0].name;
    alert(Xrm.Page.data.entity.attributes.get("new_accountid").getValue()[0].name);
    lookupData[0] = lookupItem;

     


    var parameters = {};
    parameters["subject"] = "Sales inquiry from Customer," + " " +  Xrm.Page.data.entity.attributes.get("new_accountid").getValue()[0].name;
    parameters["regardingobjectid"] = lookupData;

    Xrm.Utility.openEntityForm("email",null,parameters);

     

    }


    pnoushu@hotmail.com

    Monday, December 16, 2013 3:20 PM

Answers

  • Tried that. Try to use
    pType: 1
    instead of
    pType: "account"


    Dynamics CRM MVP/ Technical Evangelist at SlickData LLC
    My blog

    • Marked as answer by P Noushad Tuesday, December 24, 2013 2:32 PM
    Monday, December 23, 2013 2:54 PM
    Moderator
  • Dear Andrii,

    Thanks alot.  I could fix the issue by using your solution.

    Can we set default value of partylist, I mean To:  of email activity.

    Regards,


    pnoushu@hotmail.com

    • Marked as answer by P Noushad Tuesday, December 24, 2013 2:34 PM
    Tuesday, December 24, 2013 2:33 PM

All replies

  • Hello,

    Recheck following article - http://a33ik.blogspot.com/2013/01/open-new-activity-form-with-regarding.html


    Dynamics CRM MVP/ Technical Evangelist at SlickData LLC
    My blog

    Monday, December 16, 2013 5:03 PM
    Moderator
  • Hi,

    I have created 3 parameters (parameter_regardingname,parameter_regardingid,parameter_regardingtype) on the parmeters of custom entity form. I pasted below code on function Form_onload() of custom entity.  But I am getting error: Object expected , The value of the property form onload() is null or undefined or not function object.  Please help to solve this issue.

    var param=Xrm.Page.context.getQueryStringParameters();
    alert(param);'

    var regardingId=param["parameter_regardingid"];
    alert(regardingId);
    var regardingName=param["parameter_regardingname"];
    alert(regardingName);
    var regardingType=param["parameter_regardingtype"];
    alert(regardingType);


    if (regardingId != undefined)
    {
    Xrm.Page.getAttribute(“regardingobjectid”).setValue([{id:regardingId, name:regardingName, entityType:regardingType}]);
    }

     


    pnoushu@hotmail.com

    Tuesday, December 17, 2013 1:07 PM
  • Hi Andrii,

    Please let me know if there is any issue in my coding.  Please help me solve this issue.

    Regards,

    Noushd


    pnoushu@hotmail.com

    Sunday, December 22, 2013 1:05 PM
  • Try to change

    Xrm.Page.getAttribute(“regardingobjectid”)

    to

    Xrm.Page.getAttribute("regardingobjectid")


    Dynamics CRM MVP/ Technical Evangelist at SlickData LLC
    My blog

    Sunday, December 22, 2013 1:20 PM
    Moderator
  • Dear Andrii,

     

    Please provide the solution in details.  Should I create parameter pId,pType,pName etc.  Please help me to solve this issue by providing details solution.

     

    var params = {
        pId: referenced record id,
        pType: referenced record type code,
        pName: referenced record display name
    };

    Xrm.Utility.openEntityForm("task", null, params);


    pnoushu@hotmail.com

    Sunday, December 22, 2013 1:23 PM
  • No, you don't need to create pId and so on. This is in-built parameters.

    Dynamics CRM MVP/ Technical Evangelist at SlickData LLC
    My blog

    Sunday, December 22, 2013 1:27 PM
    Moderator
  • Hi Andrii,

    As you suggested, I changed code as mentioned below in email button. But it is not working.  Please find below codes I have given step by step.  Please provide me the detailed solution to solve this issue.

    1. Created button on the custom entity form as shown below screen. when click on this email button it is calling email activity. I can set subject as Sales Inquiry from Customer, 3M.  But I can't set default regarding I need to set regarding either Account so user can click on the link to reach on that account  or ID of the custom entity as default regarding.

    2. I created java web resources to call email activity with the default subject and regarding. But it is giving error.


    pnoushu@hotmail.com

    Monday, December 23, 2013 5:57 AM
  • Based on your previous code I can assume that you should replace code

    var params = {
        pId: referenced record id,
        pType: referenced record type code,
        pName: referenced record display name
    };

    with code

    var params = {
        pId: Xrm.Page.data.entity.attributes.get("new_accountid").getValue()[0].id,
        pType: "account",
        pName: Xrm.Page.data.entity.attributes.get("new_accountid").getValue()[0].name
    };


    Dynamics CRM MVP/ Technical Evangelist at SlickData LLC
    My blog

    Monday, December 23, 2013 6:39 AM
    Moderator
  • Hi,

    I changed code but it is giving error.  Please find attached image for your reference.


    pnoushu@hotmail.com

    Monday, December 23, 2013 1:12 PM
  • I'm really sorry but this is the task you have to do with yourself. You should learn how to debug JS of your webresources.


    Dynamics CRM MVP/ Technical Evangelist at SlickData LLC
    My blog

    Monday, December 23, 2013 1:18 PM
    Moderator
  • Hi,

    I did check value by alert, it is giving correct value that means getting value is correct. It open new email with subject as Sales inquiry from Customer, 3M  where 3M is the account name. So it sets default value of account and open email when click on email button.  So there is no issue in coding.  I will appreciate if you can try the same to set regarding object for opening email activity instead of task activity. Please...

    Regards,

    Noushad


    pnoushu@hotmail.com

    Monday, December 23, 2013 1:33 PM
  • Tried that. Try to use
    pType: 1
    instead of
    pType: "account"


    Dynamics CRM MVP/ Technical Evangelist at SlickData LLC
    My blog

    • Marked as answer by P Noushad Tuesday, December 24, 2013 2:32 PM
    Monday, December 23, 2013 2:54 PM
    Moderator
  • Dear Andrii,

    Thanks alot.  I could fix the issue by using your solution.

    Can we set default value of partylist, I mean To:  of email activity.

    Regards,


    pnoushu@hotmail.com

    • Marked as answer by P Noushad Tuesday, December 24, 2013 2:34 PM
    Tuesday, December 24, 2013 2:33 PM