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 :
Service | Customer Service, Contact Center, Fie...
Unanswered

Linking to multiple records on click of button

(0) ShareShare
ReportReport
Posted on by 355

Hi,

Using 'Xrm.Navigation.navigateTo', I am opening a custom entity 2 form in the create mode on click of custom button which is on dashboard sub grid view of entity 1.

I managed to link from entity 1 to entity 2 on 'save and close' of the modal form of entity 2 and populating the lookup field on entity 2 with the value of entity 1 but I also need to link with multiple selection of entity 1 records from dashboard view(Because it should cope up with selection of one record or multiple records) so for that I have created a 1:N relationship from entity 2 to entity 1 and placed the lookup field on entity1 but I am struggling to link multiple entity 1 records with entity 2, I am using the below code to do the linking from one entity to other and populating lookup so could someone help me on how to achieve the linking of 1 to many records. 

Basically idea is if I open the newly created entity 2 record, I would like to see all the records those were selected from the dashboard view of entity 1 in the sub grid of entity2.

Many thanks for your help.

var pageInput = {};
pageInput.createFromEntity = {
entityType : "entity1",
id : currentRecordId,
name : currentRecordName
}
pageInput.relationship = {
attributeName: "new_lookupfieldid",
name: "new_entity1_entity2",
relationshipType: 1,
roleType: 1
}
pageInput.pageType = "entityrecord";
pageInput["entityName"] = "entity2";
pageInput["formId"] = "9989E543-6DBB-4139-B008-BB9B7CD5A51E";
var formParameters = {};
formParameters["name"] = "Test record created";
pageInput.data = formParameters;
var navigationOptions = {target: 2, position: 1, width: {value: 50, unit:"%"}, title:"Test Record"}
// Open the form.
Xrm.Navigation.navigateTo(pageInput,navigationOptions).then(
function (success) {
//console.log(success);
},
function (error) {
//console.log(error);
});

  • Ray Profile Picture
    1,537 on at

    If I understand your question correctly, you want to set lookup field in Entity1 when open Entity2 create form? How can you set lookup field without the Entity2 id? And subgrid would not show when form is in Create mode, only after creation, subgrid would show records, maybe you can pass the selected ids of entity1 as a parameter and do some logic in save event or in backend.

  • NEWGuy Profile Picture
    355 on at

    Hi R@y,

    Thank you for reading my query. I knew other ways to do it like by saving the selected records Id's and splitting them and linking back on the lookup of the Entity 1.

    But I just want to see if is there any other solutions for many to one relationship similar to how we link one to one records using the above code.

    Also to note, that I am calling the form of Entity2 on click of custom button on Entity 1.

    If there is no easy solution then you are right either I need to get the Id's and link the records or as you mentioned to pass the parameters and link on save of the record.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Daniyal Khaleel Profile Picture

Daniyal Khaleel 58 Most Valuable Professional

#2
Travis South Profile Picture

Travis South 37

#3
11manish Profile Picture

11manish 22 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans