0

I have written a JavaScript function that opens a new Phone Call Entity form from ribbon button clicked in the Contact form. I have managed to pass open the new phone call, however I am battling toi find a way to set the values from contact in the nerw phone call form. Please view my code below

    function OpenPhoneCall()
    {
      Xrm.Utility.openEntityForm("phonecall",null,parameters);
    }

This works fine,it redirects to phone call and all, my challenge is passing values from the Contact to Phone Call entity, I saw examples that only set default values, I want to make it generic and set let it read the values in Contact and set them in the Phone Call form.

Please look at the full Code below to get the parameters from the Contact, now how do I set them in Phone Call:

function OpenPhoneCall() {

    var parameters = 
        {
            numberToDial:Xrm.Page.getAttribute("mobilephone").getValue(),
            mobileUserName :Xrm.Page.getAttribute("new_receivecallon").getValue(),
            mobileUserPassword: Xrm.Page.getAttribute("telephone1").getValue()
        };


    Xrm.Utility.openEntityForm("phonecall",null,parameters);
}

I would really appreciate some advice on how to archive this, as I see many examples on the net show how to set default values, NOTE: I am passing null for second parameter in the openEntityForm JS Method as I do not want to open an existing record, a new one. Thanks in advance.

Papi
  • 555
  • 13
  • 40
  • 1
    this seems consistent with the msdn https://msdn.microsoft.com/en-us/library/Gg334375.aspx#BKMK_ExampleXrmUtilityOpentEntityForm – Alex Aug 06 '15 at 13:18
  • Hi Alex, here they are setting default values using strings(hardcoded values), I need to pass the values read from previous form to second form. – Papi Aug 06 '15 at 13:22

1 Answers1

1

Your code is correct, the error is in the field names in parameters.

Example: open a phone call from a contact, grabbing the mobile number and using it as phone number of the activity:

var params = {
    phonenumber: Xrm.Page.getAttribute('mobilephone').getValue()
};
Xrm.Utility.openEntityForm("phonecall", null, params);
Alex
  • 23,004
  • 4
  • 39
  • 73
  • The code works, it passes the values correctly to the specified fields, Thanks a lot Alex. – Papi Aug 06 '15 at 14:29