
I have the need to pass parameters from the current form/record via the " New Record" button at the bottom of a lookup field.
I can already do this using Ribbon Workbench on Sub-grids and that works quite well.
However I also need to do it on the particular object circled in light blue as shown in the screen shot above.
How or what do I need to do to access the code behind this so I can change it to include code similar to what is shown below.
Can this be accessed via Ribbon Workbench the same as I have accessed other buttons on the sub-grid and form for example, or is this something different?
var formContext = primaryControl;
var globalContext = Xrm.Utility.getGlobalContext();
var client = Xrm.Utility.getGlobalContext().client.getClient();
if (client == "Web") {
if (rescom == 923190000 && interiorexterior == 923190000) {
HideExteriorTabs(executionContext);
if (SubGridName == InteriorTrim) {
var parameters = {};
parameters["interiorexterior"] = 923190000;
// Define the entity name to open the form
var entityFormOptions = {};
entityFormOptions["entityName"] = "scenariotrim";
Xrm.Navigation.openForm(entityFormOptions, parameters).then(
function (success) {
console.log(success);
},
function (error) {
console.log(error);
});
}
}
} Unfortunately you can't add script on that highlighted button. However, as soon as the new form opens you can add script at onload to get data from previous entity.
UPDATE
Other workaround is, add a button at the form where your lookup field is available. Now from here you can open form of that lookup entity and add parameters of whatever you want to pass. Please refer below article to open new form and to pass parameters to it.