Hello,
Does anyone know if it is possible to add two customer views to a lookup field using the addCustomView call?
Thank you
Announcements
Hello,
Does anyone know if it is possible to add two customer views to a lookup field using the addCustomView call?
Thank you
Hi Andrew,
I am trying with the same scenario,But for me I have 2 different entities that are bind to lookup on which we are adding customview.I am getting only results from first addCustomView not from second addCustomView.Any pointers that can help?
Thanks in advance.
That did the trick! You sir are a genius!
You use the same guid for the view:
Fix it and you should be good. Good luck.
Thanks Andrew!
I think I'm using different GUIDs (or at least fetching everything correctly) but when I look at the field after publishing I only see the later of the two views (Invoices by Billing Account). My code is below (it needs to be cleaned up a bit but hopefully it gets everything correctly).
/* function addCustomInvoiceView(executionContext) input - executionContext output - N/A description - takes the value entered in the RMA field, Service Account and Billing Account fields to create two customer views */ function addCustomInvoiceView(executionContext) { let formContext = executionContext.getFormContext(); // get form context if ( !formContext.getAttribute('po_rma').getValue()[0].name || !formContext.getAttribute('po_serviceaccountid').getValue()[0].name || !formContext.getAttribute('po_billingaccountid').getValue()[0].name ) { console.log("One of the following values were not found: RMA #, Service Account and Billing Account"); } else { let viewID = '{00000000-0000-0000-0000-000000000001}'; // dummy GUID let entityName = 'invoicedetail'; let invoicesServiceAccountName = "Invoices By Service Account"; let invoicesBillingAccountName = "Invoices by Billing Account"; let rmaProductNumber = formContext.getAttribute('po_rmaproduct').getValue()[0].name; let rmaProductGUID = formContext.getAttribute('po_rmaproduct').getValue()[0].id; let serviceAccountName = formContext.getAttribute('po_serviceaccountid').getValue()[0].name; let serviceAccountGUID = formContext.getAttribute('po_serviceaccountid').getValue()[0].id; let billingAccountName = formContext.getAttribute('po_billingaccountid').getValue()[0].name; let billingAccountGUID = formContext.getAttribute('po_billingaccountid').getValue()[0].id; Xrm.WebApi.online.retrieveRecord("msdyn_rmaproduct", rmaProductGUID, "?$select=_msdyn_product_value").then( function success(result) { let _msdyn_product_value = result["_msdyn_product_value"]; let _msdyn_product_value_formatted = result["_msdyn_product_value@OData.Community.Display.V1.FormattedValue"]; let _msdyn_product_value_lookuplogicalname = result["_msdyn_product_value@Microsoft.Dynamics.CRM.lookuplogicalname"]; let productGUID = "{" result._msdyn_product_value "}"; let fetchXMLServiceAccount = createFetchXML(rmaProductNumber, productGUID, serviceAccountName, serviceAccountGUID); let layoutXMLServiceAccount = createLayoutXML(); let fetchXMLBillingAccount = createFetchXML(rmaProductNumber, productGUID, billingAccountName, billingAccountGUID); let layoutXMLBillingAccount = createLayoutXML(); formContext.getControl('po_custominvoicelinefilterid').addCustomView( viewID, entityName, invoicesServiceAccountName, fetchXMLServiceAccount, layoutXMLServiceAccount, true); formContext.getControl('po_custominvoicelinefilterid').addCustomView( viewID, entityName, invoicesBillingAccountName, fetchXMLBillingAccount, layoutXMLBillingAccount, false); }, function(error) { //Xrm.Utility.alertDialog(error.message); // default error.message console.log(`addCustomInvoiceView/Xrm.WebApi.online.retrieveRecord/error.message: ${error.message}`); } ); } } function createFetchXML(productNumber, productGUID, accountName, accountGUID) { let fetchXML = "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""; return fetchXML; } function createLayoutXML() { let layoutXML = "" "" "" "" "" "" ""; return layoutXML; }
Hello,
That sounds absolutely doable. The main point - use different Guids for views when you add.
Daivat Vartak (v-9d...
671
Super User 2025 Season 1
Vahid Ghafarpour
167
Super User 2025 Season 1
Muhammad Shahzad Sh...
138
Most Valuable Professional