You should change your LookupObjects
function to LookupObjectsWithCallback
function:
LookupObjectsWithCallback(callbackReference, null, "multi", gridTypeCode, 0, null, "", null, null, null, null, null, null, viewId, [customView], null, null, null, null, null, null, 1);
And invoke it in the code like this:
displayFilteredLookupView: function (gridTypeCode, gridControl, fetch, layout, viewName) {
var viewId = "{3D02B064-4D8D-4E7C-B919-965D5D2C225D}";
var relName = gridControl.GetParameter("relName"),
roleOrd = gridControl.GetParameter("roleOrd");
// Creates the custom view object.
var customView = {
fetchXml: fetch,
id: viewId,
layoutXml: layout,
name: viewName,
recordType: gridTypeCode,
Type: 0
};
// Get all necessary parameters, that you want to pass into your callbackReference function.
SDK.Entity.BillingAccount.callbackReference.gridTypeCode = gridTypeCode;
SDK.Entity.BillingAccount.callbackReference.relName = relName;
SDK.Entity.BillingAccount.callbackReference.roleOrd = roleOrd;
// Pops the lookup window with our view injected.
LookupObjectsWithCallback(SDK.Entity.BillingAccount.callbackReference, null, "multi", gridTypeCode, 0, null, "", null, null, null, null, null, null, viewId, [customView], null, null, null, null, null, null, 1);
}
Where your SDK.Entity.BillingAccount.callbackReference
is an object with properties callback
, gridTypeCode
, roleOrd
, relName
:
callbackReference: {
callback: function (lookupItems) {
// Once the lookup window is closed, we need the parent record ID and ETC before associating selected records.
if (lookupItems && lookupItems.items.length > 0) {
var parent = GetParentObject(),
parentId = parent.id,
parentTypeCode = parent.objectTypeCode;
//associates the selected records
AssociateObjects(parentTypeCode, parentId, SDK.Entity.BillingAccount.callbackReference.gridTypeCode, lookupItems, IsNull(SDK.Entity.BillingAccount.callbackReference.roleOrd) || SDK.Entity.BillingAccount.callbackReference.roleOrd == 2, "", SDK.Entity.BillingAccount.callbackReference.relName);
}
},
gridTypeCode: null,
roleOrd: null,
relName: null
}