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

Announcements

No record found.

News and Announcements icon
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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 83

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 76 Super User 2026 Season 1

#3
Subra Profile Picture

Subra 49

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans