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 :
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,983 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

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

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 70 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 33 Most Valuable Professional

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans