web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

JavaScript: openEntityForm (phonecall)

(0) ShareShare
ReportReport
Posted on by 10,727 User Group Leader

I have used openEntityForm before, to great effect! Now I need to have a ribbon button that opens a phone call.

I am struggling to workout what code to use to pass in the "to" and "regarding" fields.

I have tried variations around ....

var param = {};

param["regardingobjectid"] = ---an ID----

param["regardingobjectidname"] = ---- a name ----

param["regardingobjecttype"] = "opportunity";

Xrm.Utility.openEntityForm("phonecall",null, param);

I have tried similar code but just passed a simple field (phone number) and that works. So I seem to have something wrong on lookup fields.

Can someone please give correct code to set the "to", "from" and "regarding" fields? In my case I need to set the "to" to the contact from an opportunity and the regarding to be an opportunity.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Aiden Kaskela Profile Picture
    19,696 on at

    Hi Neil,

    Unfortunately, you can't set the values for a partylist or regarding lookups (probably because you would need to specify any entity, which seems lazy becuase you can set a customer field) - per msdn.microsoft.com/.../gg334375.aspx

    I know it's not the answer you wanted, but if you would mark this as a Verified answer I'd appreciate it.

    Thanks,

     Aiden

    EDIT: There are limits on the custom entity that can be set, too. This must be because you would have to specify the "type" multiple times in the query string to indicate which record is which type. Having multiple keys in the request string would mess up reading in the values, so that has to be why.

  • Rajkumar Rajaraman Profile Picture
    on at

    No, it's not possible since it's an party list lookup

  • Guido Preite Profile Picture
    54,086 Moderator on at

    a workaround is to pass custom querystring parameters and parse them inside the onload event in order to fill the lookup/partylist.

    but it requires additional coding/customization, up to you to decide if good or not solution

  • Suggested answer
    Aileen Gusni Profile Picture
    44,524 on at

    Hi Neil,

    Based on this post:

    community.dynamics.com/.../114859

    community.dynamics.com/.../145341

    Party List (which is TO is part of Customer party list) and also Regarding field cant be set through the form params.

    But it needs some workaround,

    msdn.microsoft.com/.../jj860466(v=crm.6).aspx

    "Party list lookup fields can’t be set. This means the To or From fields for emails or the Regarding field for tasks can’t be set this way. The workaround is to pass the values through using a custom form parameter and then use script in the form Onload event to set the values. The Form Query String Parameter Tool detects any custom form parameters and allows you to test setting values for them."

    So you need to pass some value using custom param like string to store the name and ID then use this kind of snippet of code:

    rajeevpentyala.wordpress.com/.../get-and-set-partylist-fields-using-jscript

    Hope this helps.

    THanks

  • Verified answer
    Neil Parkhurst Profile Picture
    10,727 User Group Leader on at

    MANY THANKS Aileen, I didn't follow exactly the details in the blog posts you sent me. But your suggested workaround gave me enough detail to know what to try. And it worked perfectly.

    Got me out of a big hole!

  • Suggested answer
    Kruthi Profile Picture
    25 on at

    Set reagrdingobjectid and To as follows:

    var parameters = {};

       //set regardingobjectid

       parameters["pId"] = Xrm.Page.data.entity.getId();

       parameters["pName"] = Xrm.Page.getAttribute("fullname").getValue();

       parameters["pType"] = "2";

       //Set To field

       parameters["partyid"] = Xrm.Page.data.entity.getId();

       parameters["partyname"] = Xrm.Page.getAttribute("fullname").getValue();

       parameters["partytype"] = "2";

  • Suggested answer
    Kjeld Poulsen Profile Picture
    180 on at

    This is actually a good answer, and it works. The regarding and to pary is set as expected.

    [quote user="Kruthi"]

    Set reagrdingobjectid and To as follows:

    var parameters = {};

       //set regardingobjectid

       parameters["pId"] = Xrm.Page.data.entity.getId();

       parameters["pName"] = Xrm.Page.getAttribute("fullname").getValue();

       parameters["pType"] = "2";

       //Set To field

       parameters["partyid"] = Xrm.Page.data.entity.getId();

       parameters["partyname"] = Xrm.Page.getAttribute("fullname").getValue();

       parameters["partytype"] = "2";

    [/quote]

    But if you in same process tries to also set the phonenumber  parameters["phonenumber"] = "xyz", because you have i on hand, iand wish it should be visible on the newly opened form, the telephone number will stay blank, even when parsed.  Pretty anoing.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans