Thursday, 19 July 2012

Yesterday, I faced a weird behaviour of order product entity on production server & in fact did not visualize the same during development phase. This is related to a default lookup view of existing product on Order Product entity record.

In Dynamics CRM a default lookup view for this entity is “Products in Parent Price List”. Means you will only be allowed to select the products of Price List that was selected on Order record (Parent record). On yesterday I found that the default view was changed to “Product Lookup View” and it now allows you to select products of all Price Lists. Weird….

After goggling for an hour I came to know that this is because I wrote some JavaScript code on change event of this lookup field to do some calculation of pricing based on product selection. So when you write custom code on the OnChange event of such "special" lookups CRM loses its normal behaviour.

Workaround

Create a new temporary unmanaged solution on development organization.

Add an Order Product entity to this solution.

Export this solution as unmanaged.

Unzip the customization files.

· In customiztaion.xml, change the default view GUID back to “Products in Parent Price List” ({BCC509EE-1444-4A95-AED2-128EFD85FFD5}) by replacing the current GUID of “Product Lookup” ({{8BA625B2-6A2A-4735-BAB2-0C74AE8442A4}}).

Import the solution back to the development organization & publish the changes.

You can now validate the default lookup view for Product lookup.

Now, export your original unmanaged solution as Managed to be imported on production server.

Hello Ankit, I removed the code on the change event but the behavior is still the same, i get all the products listed outside of the selected price list. So I am really not sure that by adding some on change code the behavior is changed. can you share any specific links on this.

Out-of-the-box this lookup should only display the products of parent price list. So, if you are getting all the products listed outside of the selected price list then please follow the steps specified on above. After applying the workaround you would be able to see the parent price list products only.

Maybe I am not understanding this correctly but that is what I did. I placed a java onchange on the productid of the sales order form so when a product is selected it automatically enters the UOM in the field. When I do this I loose the Products in Parent Price List.

I would recommend pushing the Price List lookup value from the Order to the Order Product form and adding a custom view to the ProductId field on load of the form using javascript. This avoids any direct editing of the XML while also providing control over the look and feel of the view. Key steps: 1. create Price List on Order Product form, 2. ensure the Price List fields are mapped between Order and Order Product, 3. create a formload javascript that uses the 'addcustomview' method for crm controls, 4. ensure the form load event triggers the javascript

I am having the same issue now with my Quote Product Entity. I am assuming the solution is similar. Do you know if the default GUID in customization.xml would be changed to the same value in or example?

This Solution worked until Rollup 14. Seems that Microsoft has now hidden the View... In customiztaion.xml, change the default view GUID back to “Products in Parent Price List” ({BCC509EE-1444-4A95-AED2-128EFD85FFD5}) by replacing the current GUID of “Product Lookup” ({{8BA625B2-6A2A-4735-BAB2-0C74AE8442A4}}).

About Me

Ankit Shah is highly motivated and experienced professional, Bachelor Science in Information Technology -B.Sc. (I.T.) securing more than 8 years of IT experience on software design and development.
Presently Ankit is working as a Dynamics CRM consultant at Inkey Solutions, Surat, India.