다음을 통해 공유


CRM 2011 Prepopulating Opportunity and Quote Price List, Unit and Quantity.

Recently I've been presented a number of scenarios where the built in CRM Opportunity and Quoting modules are very close to what is needed for a given customer requirement.  However the process does not need or really want to use pricelist, Unit or quantity for a product on the Opportunity or Quote..

So the challenge…

My scenario calls for using the product’s with Opportunities and Quotes to support the forecasting and quota modules,  however I don’t have any complexity in my product catalog. Its is a flat list of products with flexible pricing and quantity support.  I do not need more then one pricelist, nor do I need multiple Unit specifications.

to support this,  lets say we have defined a product called PROD001,  PROD001 is on the Default Price List, with a Price List Cost of $10.  It is also associated to the Primary Unit, with a default quantity of 1.  

The Product looks like:
image

The Primary Unit looks like:
image

Remember that Default Unit “owns” the Primary Unit…

And on the Default Price List I have a Price List Item
image

Which looks like :
image

Now I want to create a Opportunity….  Using the default functionality; I go to Sales, Opportunities, and click “New”,  I populate the Topic and Customer and click save…
Now I navigate to the Line items area..

My view looks like this:
image

On the Ribbon, I click “Add New Opportunity Product”…

I am promptly given an Error:
image

Ok, So I need to:

  1. Click the search box next to Price List ( or type it in if I know the name ).
  2. Choose the Default price List in the Lookup.
  3. Click Save.
  4. THEN save the form

All to get me this view:
image

That’s a lot of work for a field I didn’t care about…

So now Im ready to add a product,  Once Again I click “Add New Opportunity Product”…
image

I click the search button on the existing product and Select PROD001

Now I have this..
image

Ok, so I can see by the Red * that I need a Unit and a Quantity to proceed.

So again.. I need to Click the Search button and Populate the unit, then key the quantity I'm interested in..  THEN hit save.

The net result is I get back to this:
image

Looking back at the overall flow here,  Iv got perhaps 3 save’s and 9+ clicks I need to do to enter information that is repeated every time and my user doesn't really care about anyway…   Not a good situation…

Solving for Required, but Ignored fields. 

The obvious answer is to remove them from the form, however that not going to work as they are required for the “normal” function of CRM. 

After giving this a bit of though I came up with a solution that prepopulates most of this “Extra” information from defaults, which allows you to hide the fields in question and still leverage the core features of CRM’s product / Opportunity and Quoting modules.

While I could hard code in ID’s or names to a Onload JavaScript for the various forms,  I want to give the developer and user the flexibility to configure the default pricelist, and the relationships for the Product / Unit and quantity that will auto populate.   My thinking here is while these fields are not necessary in the day to day operations, they can be used to speed data entry and reporting.

So the plan was to be able to create a relationship such as :

  • PROD001 (Product)
    • Primary Unit  ( Unit Relationship )
      • Quantity: 1
  • PROD002 (Product)
    • Batch (Unit Relationship )
      • Quantity: 10
  • Default ( PriceList)
    • PriceList Item for PROD001
      • Product : PROD001
      • Amount: $10
    • PriceList Item for PROD002
      • Product : PROD002
      • Amount: $15

and so on..   This way the user can set the default quantity behavior for any given product by adjusting the default Unit on the product.
Note:  the relationship from the PRODUCT to the UNIT is the determining relationship in this process, not the relationship on the pricelist,

What I chose to do was to create a JavaScript module that did the following:

On Create Opportunity and Quote:

If the Price List is not populated already, Use a hint key to populate the Price List from the system.. by default its going to look for a pricelist that starts with “Default”

On Add Product to Opportunity Product or Quote Line Item

Use the default association between Product, Unit, and Unit quantity to populate the appropriate fields on the form.
this allows the user to configure the default unit and quantity numbers on a per product bases. IE: Each / Batch / etc..

JavaScript vs a Plugin,
I did consider using a plugin to associate the default pricelist with an Opportunity or Quote, but decided to keep it all in the front end for now.

This functionally drops 9 or so Clicks and 3 save actions along the way… which balances things out a bit.

You can find the Managed and Unmanaged solutions that contains the JavaScript web resource to do this job here.
There are 2 web resources in the solution,

  • mattb_ProductViewSettings
  • mattb_ProductViewSettings_UnCompressed

They are both the same file,  one is minimized, one is not.

Additionally I have provided the opportunity, quote, opportunity product, and quote line item form event updates as part of the solution.
When in doubt, use the managed solution.

Warnings:

Note: If you import the Managed solution and maintain the existing customizations ( Don’t step on the forms there if they are customized ), you will need to add in these events by hand.

If you don’t know if your opportunity / quote forms are customized… use the managed solution …  

You can always copy the JavaScript code out of the mattb_productViewSettings_UnCompressed in the managed solution and add it to a web resource in your solution.

As provided, the JavaScript will look for any pricelist that begins with the word “Default”,  and if there is more then one, use the first one in runs into.
To change that, open the web resource and locate the line :

    1: DefaultPriceListStartsWith: "Default",

Then change the world Default to whatever you want the default price list to be..

For Opportunity and Quote, the form properties are wired to events as such :

image

Where mattb_ProductViewSettings has been added to the forms library collection and the Onload event has been wired to the MattB.ProductViewSettings.OppQuoteDefaultPriceList method of the mattb_ProductViewSettings.

For the Line item forms.,

The Form properties are set to:

image

and the properties on the “product” field have been set to:

image

So in text: 
mattb_ProductViewSettings has been added to the forms library collection of the Quote Line Item and Opportunity Line Item, Then I viewed properties on the Existing Product field, selected events, and added MattB.ProductViewSettings.ProductDefaultUom to the OnChange event

with that done,

When I create a new opportunity,  the Price List is auto populated and saved on the first save, which I need to do to activate the line items area.

image

And when I click “Add New Opportunity Product”  and select a product

image

Unit and quantity auto populate… 

Also because Unit is driving the base quantity, if I choose a product with a different unit:

image

It populates the updated quantity based on the unit associated.

There we go… a bit of prepopulating to help get things moving a bit faster and save some mouse clicks and key strokes.

Enjoy!.

Comments

  • Anonymous
    August 31, 2012
    This is brilliant.

  • Anonymous
    June 28, 2013
    Hi, this is awesome, exactly what I've been looking for.  One issue i have, after applying the managed solution, my default price list is correctly selected on form load, but i still have to click save before i can add products.  Default unit and quantity work also, its just the initial save that i still have to do.  Any ideas?

  • Anonymous
    December 17, 2013
    Hi.  This worked spectacular in CRM 2011, do you know if it will work with CRM 2013?  if not, will you be making a jScript for CRM 2013?  Thank you.