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 :
Customer experience | Sales, Customer Insights,...
Answered

Open Create form with JavaScript navigateto function and associate.

(0) ShareShare
ReportReport
Posted on by 185

I am looking at using the JavaScript navigateto to open up a form of another entity and associate that record that ultimately gets created with the record they triggered the create from. It is an M:M relationship type  

I have had a look at the Documentation https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-navigation/navigateto but just wondering if someone has an example of using the optional relationship parameter?

I have the same question (0)
  • Verified answer
    Bipin D365 Profile Picture
    28,985 Moderator on at

    Hi,

    Please check below article which has sample code given in comments section on the blog.

    www.inogic.com/.../

    var pageInput = {};
    
    var accountId = Xrm.Page.data.entity.getId();
    accountId = accountId.replace(“{“, “”).replace(“}”, “”);
    
    pageInput.createFromEntity = {
    entityType : “account”,
    id : accountId
    , name : Xrm.Page.getAttribute(“name”).getValue()
    }
    pageInput.relationship = {
    attributeName: “parentcustomerid”,
    namme: “contact_customer_accounts”,
    relationshipType: 1,
    roleType: 1
    }
    pageInput.pageType = “entityrecord”;
    pageInput[“entityName”] = “contact”;
    
    // Set default values for the Contact form
    var formParameters = {};
    formParameters[“firstname”] = “Sample”;
    formParameters[“lastname”] = “Contact new “;
    formParameters[“emailaddress1”] = “contact@adventure-works.com”;
    formParameters[“jobtitle”] = “Sr. Marketing Manager”;
    formParameters[“donotemail”] = “1”;
    formParameters[“description”] = “Default values for this record were set programmatically.”;
    
    pageInput.data = formParameters;
    
    // Open the form.
    Xrm.Navigation.navigateTo(pageInput).then(
    function (success) {
    console.log(success);
    },
    function (error) {
    console.log(error);
    });

    Please mark my answer verified if i were helpful

  • LeoAlt Profile Picture
    16,331 Moderator on at

    Hi Partner,

    "Relationship" attribute is used to set lookup field on entity form, it is available only in "Entity Form" not "Entity List".

    And as you said your entities have N:N relationship, so you need to set "relationship type" to "1".

    And in Kumar's link, you could refer to the comments after the article.

    pastedimage1599725436727v1.png

    Best Regards,

    Leo

  • stuaz Profile Picture
    185 on at

    Thanks guys I will check that out. I did do some googling prior to asking but didn’t think to check the comments on pages!

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 > Customer experience | Sales, Customer Insights, CRM

#1
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

#2
ManoVerse Profile Picture

ManoVerse 66 Super User 2026 Season 1

#3
11manish Profile Picture

11manish 45

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans