Friday, March 28, 2008

Removing the Price List field from an Opportunity

The Price List field is an interesting field in that it is a field has script that fires from it but you cannot see it from the form editor where you place your own scripts. I recently tried removing this field from an Opportunity and the Account form. The Account didn't show any repercussions but the Opportunity wouldn't allow me to add an Opportunity Product to the Opportunity.

With the Price List field missing I just got this random non-descript scripting error. When I added the field back and tried to add an Opportunity Product I received the error I expected of having no Price List set. The problem now became that when I tried to select a Price List for the Opportunity I couldn't see any Price Lists to choose from. Basically the script that was running and populating the filtered list of Price Lists had been removed when I removed the field from the form and it doesn't come back when I put it back onto the form.

The question now became how do I fix it? How do I get that script back. I have to give credit to Nahi for his post in the Microsoft.Crm.Public group who ran into this issue and posted the solution he found. He didn't go into the details, he just went over the process. I'm going to try and give you a little bit more.

Basically the idea was, grab the script from another entity or another system where the Price List had not been removed. The way to do that is to export the Opportunity and look through the entity XML for the missing script. Then copy and paste the script XML into the entity XML of the entity that had the Price List field removed from it. Save changes and reimport it back into CRM, publish and you're set. It worked great for me and I now no longer have any issues with the Opportunity, Price List or adding Opportunity Products.

The best way to find the script from the clean entity XML is to search for "Price List" and then look through to where you see the script next to one of your finds for "Price List". Here's the XML block that I found and added (it should go between the LABEL and CONTROL tags):

<events>
<event name="setadditionalparams" application="true" active="true">
<script>
<![CDATA[
var oLookup = event.srcElement;
AddTransactionCurrencyParam(oLookup);]]>
</script>
<dependencies>
<dependency id="transactioncurrencyid" />
</dependencies>
</event>
</events>

Hope this helps someone else out.

David Fronk
Dynamic Methods Inc.

17 comments:

Unknown said...

Thx a lot ;)

Anonymous said...

This was incredibly helpful. Many, many thanks for taking the time to submit this post.

Anonymous said...

This was incredibly helpful. Many, many thanks for taking the time to submit this post.

Andrew said...

This was incredibly helpful. Many, many thanks for taking the time to submit this post.

Maria said...

Thank you! You just saved my ass :)

Dynamic Methods said...

Glad to be of help Maria.

David Fronk
Dynamic Methods Inc.

Anonymous said...

Hey, thank's for that!!!

Anonymous said...

Anyone else have this problem where this soln. didn't resolve it?
When I re-import my opportunity object and try and open an opportunity I get an error. I've tried editing the xml a couple of different ways with no luck. I tried sticking the script before "[lessthansign]/ labels [greaterthansigh]" and after that tag. I can import with no errors, but can't get it to 'work'.

Anonymous said...

On that note, you need to add the Currency field to the Opportunity form. I found out the hard way after modifying the XML, importing, publishing and getting an error when trying to load the opportunity form.

Swati Shah said...

Hi,

Thanks for the wonderful post.
I have been able to get values in the Price List Lookup on my opportunity record finally.

But I have a problem here I have written a workflow on create of an opportunity record which need to populate a default price list on the Oppty record.
I am unable to get the list of price list inside the workflow when I update Oppty record.

Any suggestion s for that....

Dynamic Methods said...

CaprisS,

Why don't you try getting the price list from the parent account/contact? That should work.

I can't say for sure why you can't see all the price lists through workflow, though I have my theories. My guess is that since pricing is customer based or quantity based (if you are using discount lists) the logic couldn't be built out without a customer to start with.

Hopefully this gets you on your way though.

David Fronk
Dynamic Methods Inc.

Maddy said...

I tried to do it in MSCRM 4.0 Online and it did not work for me. Does this thing work only for On-Premise implementation of MSCRM?

Regards,
Madhur Halapeti

Dynamic Methods said...

Maddy,

I haven't ever run into this with CRM Online. Since you are just loading up XML configuration information I assume that it would work. However, they have locked down other parts so I wouldn't be surprised if they locked down users capabilities to upload scripts to certain out of the box fields. You may have to open a ticket with CRM Online support to get them to reapply the script. Verify your file that you're uploading and if all is in order and it still doesn't work contact the CRM Online helpdesk.

David Fronk
Dynamic Methods Inc.

Anonymous said...

Hi,
Is it possible to remove Default price list form Product or auto populate the feild, as we plan to create product through a workflow, any javascript onChage or onLoad event.

Thanks in advance

Dynamic Methods said...

I would autopopulate the field either with a workflow, if you only have a handful of price lists (1-10). Otherwise you could autopopulate it off of another record (like the default price list from the Account) using JavaScript. Here's a post that talks about how to do this:

http://dmcrm.blogspot.com/2009/02/autofill-account-from-contact-custom.html

Hope that helps,

David Fronk
Dynamic Methods Inc.

Larry T. said...

Related problem.

When I create an opportunity directly from the Sales/Opportunities/New... the price list dialog works perfectly.

However, if I use Marketing/Marketing Lists/(Select a list)/Marketing List Members/More Actions/Create Opportunity... the price list lookup throws an error

Field:pricelevelid
Event:setaddtionalparams
Error:Object Expected

I exported the Opportunity entity and looked at the xml... it appears just as shown in your article above.

Any ideas on this? Can somebody else test to see if it's working for them?

Thanks,
Larry T

Dynamic Methods said...

Larry,

I haven't seen this before, but I do know that when you create Opportunities from that Marketing List page you are using a different form type from (not the standard update or create) and that could be causing issues. I tested this in a number of systems and didn't see the error that you got.

Do you have additional scripts firing that use/effect the price list? Since it works on one form type but not another my guess is that we just need to find and handle the script that causing the issue on the mass creation form.

David Fronk
Dynamic Methods Inc.

Post a Comment