Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

passing parameters for lookup field in call to Xrm.Utility.openEntityForm

Posted on by Microsoft Employee

Hi,

I am attempting to use Xrm.Utility.openEntityForm to open a case form from within a java script.  The form contains an SLA field which I want to populate with default value when opening the form. I have found the example below which shows how to pass id, name and type parameters for lookup fields. 

function OpenNewContact() {
 var parameters = {};
 //Set the Parent Customer field value to “Contoso”.
 parameters["parentcustomerid"] = "2878282E-94D6-E111-9B1D-00155D9D700B";
 parameters["parentcustomeridname"] = "Contoso";
 parameters["parentcustomeridtype"] = "account";
 //Set the Address Type to “Primary”.
 parameters["address1_addresstypecode"] = "3";
 //Set text in the Description field.
 parameters["description"] = "Default values for this record were set programmatically.";
 //Set Do not allow E-mails to "Do Not Allow".
 parameters["donotemail"] = "1";

// Open the window.
 Xrm.Utility.openEntityForm("contact", null, parameters);
}

 From <https://msdn.microsoft.com/en-gb/library/gg334375.aspx>

From this I guess that I need to code something like the following:

parameters["slaid"] = <whatever the id is>

parameters["slaname"] = "Bronze";    //This is the name of the SLA I have created

parameters["slatype"] = "sla";   //I'm not sure if I actually need this

My question is - what is the id which I need to pass and where do I get it from?

Thanks for your help,

Roy

*This post is locked for comments

  • Suggested answer
    tpeschat Profile Picture
    tpeschat 4,926 on at
    RE: passing parameters for lookup field in call to Xrm.Utility.openEntityForm

    OK, I once again hat a look at the database.

    The fields are called "SLAid" and "SLAname".

    So please try it with:

    parameters["slaid"] = ...

    paramters["slaname"] = ...

    Hth Thomas

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: passing parameters for lookup field in call to Xrm.Utility.openEntityForm

    Sorry Gopalan, it still fails. I don't think the type parameter is required unless it is a multi-type entity like customer or owner.

    Strangely, I am able to use the same method with the subjectid lookup field, which works perfectly:

    parameters["subjectid"] = "bb9a4517-a9f9-e611-93ef-005056af7F86";

    parameters["subjectidname"] = "No Contact";

    I am using enhanced SLAs if that makes any difference.

    Roy

  • Suggested answer
    Gopalan Bhuvanesh Profile Picture
    Gopalan Bhuvanesh 11,397 on at
    RE: passing parameters for lookup field in call to Xrm.Utility.openEntityForm

    Try

    parameter["slaid"] = "F140F41A-1458-E711-93FB-005056AF7F86";

    parameter["slaidslaname"] = "Bronze";

    parameter["slaidtype"] = "sla";

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: passing parameters for lookup field in call to Xrm.Utility.openEntityForm

    Hi Thomas,

    I tried  your suggestion about leaving out the slaidname parameter. The form opened successfully this time (with the SLA field set to "(no name)" of course).

    All I need now is to figure out how to set the default sla name to "Bronze". I thought that using slaidname was a way of referencing the name field of the slaid lookup in the case form. This is similar to the code example in my initial post:

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

    parameters["parentcustomeridname"] = "Contoso";

    parameters["parentcustomeridtype"] = "account";

    Thanks for your help so far.

    Roy

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: passing parameters for lookup field in call to Xrm.Utility.openEntityForm

    Samhitha,

    The schema name for the slaid parameter is SLAId. The schema name for slatype is SLAType.

    incident is the name of the Case entity ("Case is the display name"). I am using this because it is a Case form which I want to open. This case form includes SLA as a lookup field.

  • tpeschat Profile Picture
    tpeschat 4,926 on at
    RE: passing parameters for lookup field in call to Xrm.Utility.openEntityForm

    Try just with parameter for slaid, without slaidname.

    I didn't find a field named slaidname im the filteredincident view ln db level.

    br Thomas

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: passing parameters for lookup field in call to Xrm.Utility.openEntityForm

    I have figured out that when I open the SLA and then click on the "pop out" button on the top right, it opens it in a new browser tab with the full URL, which includes the id. Different SLAs give different IDs using this method.

    I am now confident that I have got the correct id for my "Bronze" SLA, however my code is still giving an error. Is the syntax definitely correct?

    I had thought that you had to add an "id" suffix to the field name when specifying the parameter. As the field name is "slaid" adding an id suffix would make it "slaidid".

    Similarly adding a "name" suffix for the name parameter gives "slaidname". The correct syntax should thus be:

    parameter["slaidid"] = "F140F41A-1458-E711-93FB-005056AF7F86";

    parameter["slaidname"] = "Bronze";

    In any case, I have tried it with and without the id suffix and it doesn't work either way. I am running out of ideas.

    Roy

  • tpeschat Profile Picture
    tpeschat 4,926 on at
    RE: passing parameters for lookup field in call to Xrm.Utility.openEntityForm

    You're looking at the Schema of the SLA entity. But the parameters to set (lookup to SLA) is on the incident entity.

  • Suggested answer
    Samhitha Nittala Profile Picture
    Samhitha Nittala 75 on at
    RE: passing parameters for lookup field in call to Xrm.Utility.openEntityForm

    Can you verify the schema names of parameters you used from

    Settings->Customization-> Customize the system

    8814.Capture.PNG

  • tpeschat Profile Picture
    tpeschat 4,926 on at
    RE: passing parameters for lookup field in call to Xrm.Utility.openEntityForm

    Hi,

    when I navigate to Settings --> Service Management --> SLAs and then select 1 SLA and right click on it and select "copy link" I get a link that contains the slaid.

    I tried it for two different SLAs and received two different ids.

    Link looks like https://<yourcrmlink>/userdefined/edit.aspx?etc=9750&id=%7bBEAE7FA3-D55C-E711-80F8-00155D4E8722%7d

    Where the slaid id is between %7b and %7d --> 7bBEAE7FA3-D55C-E711-80F8-00155D4E8722 in my example.

    Hth Thomas

    slaid.png

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans