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)

Pass parameters to openEntityForm and set lookup field

(1) ShareShare
ReportReport
Posted on by 2,505

My plan is to add a button on a form (Contact) that opens a new Task window and fills the "regardingobjectid" lookup field. I'm working on CRM2013 fall.

I found an example here:

msdn.microsoft.com/.../gg334375.aspx

Example: Use Xrm.Utility.openEntityForm to Open a New Window

So it works great if I add the button on Account form and open Contact window.

I changed the lines

parameters["parentcustomerid"] = "2878282E-94D6-E111-9B1D-00155D9D700B";

parameters["parentcustomeridname"] = "Contoso";

parameters["parentcustomeridtype"] = "account";  

to

parameters["regardingobjectid"] = entityId;

parameters["regardingobjectidname"] = "Jim Glynn (sample)";

parameters["regardingobjectidtype"] = "contact";

and used it my scenario but I got an error message.

I could't find any documentation, just this example.

Any advices?

Here's full function (not working):

function addTask() {
var parameters = {};
var entityId = Xrm.Page.data.entity.getId();
parameters["regardingobjectid"] = entityId;
parameters["regardingobjectidname"] = "Jim Glynn (sample)";
parameters["regardingobjectidtype"] = "contact";
Xrm.Utility.openEntityForm("task", null, parameters);
}

*This post is locked for comments

I have the same question (0)
  • Verified answer
    jlattimer Profile Picture
    24,562 on at

    It isn't possible to send the Regarding field or a To/From field as a parameter.

    Have a look at this thread: Passing regardingobjectidtype to Xrm.Utility.openEntityForm

    This user's solution was to create additional input parameters on the form and have some JavaScript read them and then populate the field.

  • Suggested answer
    Community Member Profile Picture
    on at

    In case anyone else stumbles upon this question, you can set the Regarding lookup, though indirectly, by passing pId, pType, and pName.  Here is sample code to open a new task with the Regarding set to the currently open record.

    	Xrm.Utility.openEntityForm('task', null, {
    		pId: Xrm.Page.data.entity.getId().replace(/{|}/g, ''),
    		pType: Xrm.Page.data.entity.getEntityName(),
    		pName: Xrm.Page.getAttribute('name').getValue()
    	});


  • Svsaran Profile Picture
    on at

    Change the parameter 'regardingobjectidtype' to 'regardingobjecttypecode'. It will work. See the below corrected code.

    function addTask() {

    var parameters = {};

    var entityId = Xrm.Page.data.entity.getId();

    parameters["regardingobjectid"] = entityId;

    parameters["regardingobjectidname"] = "Jim Glynn (sample)";

    parameters["regardingobjecttypecode"] = "contact";

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

    }

  • Suggested answer
    Premz Profile Picture
    50 on at

    Working code for version 9.1

    var parameters = {};

    //set the regarding object id 


    parameters["regardingobjectid"] = customerId;
    parameters["regardingobjectidname"] = customerName;
    parameters["regardingobjecttypecode"] = "contact";

    Xrm.Navigation.openForm({ entityName: "appointment" }, parameters);

  • kmish Profile Picture
    50 on at

    Thanks!!!! This helped!!

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