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);
});