Its often possible that different BusinessUnits may have different PriceLists related to their various Business Requirements. This was the same case with one of my client where they want to filter the PriceLists based on their BusinessUnit selected.

The first thing which came to my mind was customizing PriceList entity and creating a 1:N relationship of PriceList with BusinessUnit. Then later filter the PriceList LookUp through FetchXml by comparing the Businessunit selected.

But the most challenging case was like, the same single PriceList can be present in various BusinessUnits as well. Now in order to maintain the integrity, it was not a good idea to create the same single Pricelist again and again (holding all the same products to it) and add different BusinessUnit to it accordingly.

Eventually for a much better solution i created another entity where i can capture the PriceList and the corresponding BusinessUnit. Then filter through FetchXml using “Link-Entity”.

The following figure shows the newly created entity “Pricelist_Config” with PriceList and corresponding BusinessUnit.

The Code goes like this :-

var val2= crmForm.all.new_businessunitid.DataValue[0]. id;
var cont2=crmForm.all.new_pricelevelid;
cont2.lookupbrowse = 1;
cont2.AddParam(‘search’,”<fetch mapping=’logical’><entity name=’pricelevel’>”
+”<all-attributes />”
+”<link-entity name=’new_pricelist_config’ to=’pricelevelid’ from=’new_pricelistid’>”
+”<filter type=’and’>”
+”<condition attribute=’new_businessunitid’ operator=’eq’ value= ‘” + val2 + “‘ />”

Now we paste the following code at “OnLoad” event of the form. Here we first capture the BusinessUnit which is used for comparison thus while selecting the PriceList shows only those PriceList names which belong to the related BusinessUnit captured.

We should also uncheck the “Enable Form Assistant” to avoid any confusion since it displays all without filtration.

Goto Settings -> Customization -> Customize Entities -> Select the Entity -> Forms and Views -> Form -> Form Properties -> Display Tab.


Its working fine for me and Hope it Helps..  🙂

Thanks !!!