Scripting the Quote Product form

You might be reading this topic, and think it’s just scripting, and just like any other form. What’s different?

Now, most fields we can script against without a problem. But let’s focus on the Extended Amount field. There is a system calculation that takes place, and if you try to enable the field for editing on the form, you will realize that you can’t.

Funny enough though, assigning a value to the field in JavaScript “almost” works.

var calculatedValue = … ; // put your formula here

Xrm.Page.getAttribute(“extendedamount”).setValue(parseFloat(calculatedValue));

Don’t be fooled by the fact that the field value indeed updates, because that’s only on the screen. Once you save the Quote Product, the value automatically gets re-calculated based on the built-in formula, and your result is off.

The way to override that value is by writing a plugin, but that’s besides the point of this post. I was looking at alternatives using JS. In some circumstances you just can’t get the result you want without writing a plugin, but for easy things, you could basically take the following approach:

  • Create a new Unit Price field on the form.
  • Hide the default Unit Price field.
  • Do your calculations based on the custom Unit price field, update the unit price (adding discounts and other adjustments you want to make), and populate the new value in the default Unit Price field (the one you have hidden).
  • Using this new price, you can take advantage of the system calculation, and make sure the Extended Price gets updated.

image

For a Write In product, this is not a problem, but for an Existing product, this will only work if Override Price is selected. Otherwise, the calculated value is based on the price as it’s defined in the price list associated product.

Enjoy!

Advertisement

One thought on “Scripting the Quote Product form

Add yours

  1. Hi Nico

    Great Post!.

    I’m interested in changing quote Total Amount behaviour, without creating a new custom field for it.

    In the post you mentioned “The way to override that value is by writing a plugin ” Could you tell me if this is possible for Total Amount?

    I know next to nothing about CRM 2011 plugings so if you have any additional information about it , it would be very helpful

    Regards

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: