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 365 | Integration, Dataverse...
Answered

Using .OpenForm Won't fill out Custom Lookup

(0) ShareShare
ReportReport
Posted on by 55

Can't seem to get this open form function to fill out more than one lookup field? It fill out regarding, which was easy to do because i got that example from the API Documentation, but then when trying to use that same example to fill out a second lookup field it won't work.

Field is "Expense Category" with schema "d365pros_projectexpensecategory", code wise my understanding is you schemaid, schemaname, and schematype at the end of each field but that doesn't seem to do anything. 

Code below.

function OpenNewForm(id, name, ProjectExpID, ProjectExpName) {
    debugger
    //https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-navigation/openform

    var entityFormOptions = {};
    entityFormOptions["entityName"] = "d365pros_approvals";

    // Set default values for the Contact form
    var formParameters = {};
    //formParameters["new_field1"] = "Sample";
    //formParameters["new_field2"] = "Sample";

    // Set lookup column Regarding - THIS WORKS!
    formParameters["regardingobjectid"] = id; // ID of the user.
    formParameters["regardingobjectidname"] = name; // Name of the user.
    formParameters["regardingobjectidtype"] = "salesorder"; // Table name.

    //This Lookup Field Won't Wor Though?
    formParameters["d365pros_projectexpensecategoryid"] = ProjectExpID;
    formParameters["d365pros_projectexpensecategoryname"] = ProjectExpName; 
    //formParameters["d365pros_projectexpensecategorytype"] = "salesorderdetail"; 

    // Open the form.
    Xrm.Navigation.openForm(entityFormOptions, formParameters).then(
        function (success) {
            console.log(success);
        },
        function (error) {
            console.log(error);
        });

}

Any help would be appreciated. 

I have the same question (0)
  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Try to use

    formParameters["d365pros_projectexpensecategory"] = ProjectExpID;

    formParameters["d365pros_projectexpensecategoryname"] = ProjectExpName;

    instead.

  • jdaniel1 Profile Picture
    55 on at

    I think that was the trick. I swear i tried that before, but I tried that again actually just after I posted this XD and of course it works now. I removed the Type altogether; I think that helped as well. 

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 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 49 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

#3
#ManoVerse Profile Picture

#ManoVerse 31

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans