Hi,
In a model driven app i've created a custom button (ribbon workbench) on a subgrid. When you click on the button it will open a quick create form from the table 'invoice'. On that quick create form I want to fill a lookup field (dossier) with the ID of the record from the page where the button is placed (dossier).
So far this works only the lookup field shows the linked record without the name (no name or undefined). When the record (invoice) is saved and you navigate to the record, the correct lookup record (dossier) is linked and you will also see that the name is displayed correctly. I retrieve the record (dossier) by an onload javascript. Var str_id is passed when the quick create form is opened
function CreateInvoiceFromDossier()
{
var ActiveSelectedRows = Xrm.Page.getControl("Subgrid_Declaraties").getGrid().getSelectedRows().getLength();
var selectedIdArray = "";
var selectedRows = Xrm.Page.getControl("Subgrid_Declaraties").getGrid().getSelectedRows();
// Get Dossier ID -> record GUID on page
var id = Xrm.Page.data.entity.getId();
var str_id = id.replace(/[{}]/gi, '')
// Get GUID of selected rows (expenses) in subgrid
selectedRows.forEach(function(selectedRow, i) {
selectedRecordId = selectedRow.getData().getEntity().getId().replace('{', "").replace('}', "");
selectedIdArray = selectedIdArray + selectedRecordId.trim() + ",";
});
// Open invoice quick create form. Set GUID (expenses, selected rows) in textarea field, add ID of page to lookup field
var RecordID = { asp_expenses_guid: selectedIdArray.slice(0, -1), asp_dossier_invoice: str_id };
Xrm.Utility.openQuickCreate("asp_invoice", null, RecordID).then(function () { console.log("Success"); }, function (error) { console.error(error.message); });
Can someone help me to set the name of the linked lookup record (dossier)?
Thanks!