For this recipe, we will focus on a different entity. Let's have a look at Opportunity. The Opportunity is the result of a qualified lead in many cases, but Dynamics CRM allows you to also add opportunities directly.
With opportunities, one of the fields we will focus on is the pipeline phase. For specific scenarios, a pipeline phase is tracked, customized, and enforced. Business rules can define the stages that define each pipeline phase, and specific rules that have to be met for an opportunity to progress to the next pipeline phase.
We can start by either reusing one of the previously created solutions or creating a new one. If you do not have a solution created, start by creating one.
We assume the following business rules
We will achieve this by using a combination of scripting and workflows. So let's get to it.
Currency
and Price List
are defined. We will perform this check in JScript, and update a temporary field with a true
/false
value. Add a two-options field to the form, named new_progressto50
.OnChange
event of both the Currency (transactioncurrencyid
) and Price List (pricelevelid
) fields:function HasCurrencyAndPriceList() { var _currency = false; var _priceList = false; var currency = new Array(); currency = Xrm.Page.getAttribute("transactioncurrencyid").getValue(); if(currency != null) { _currency = true; } var priceList = new Array(); priceList = Xrm.Page.getAttribute("").getValue(); if(priceList != null) { _priceList = true; } if(_currency == true && _priceList == true) { // set temp field to true Xrm.Page.getAttribute("new_progressto50").setValue(true); } }
True
, updates the pipeline phase to 50%.The solution presented here enforces business rules through the use of workflows, and shows an example where working with JScript in conjunction with workflows can achieve the expected result.
For the sake of simplicity, I have demonstrated the creation of four different workflows, one for each phase progression. In real life, you would build all these rules in a single workflow. Additionally, you would probably build a reversed process that would downgrade the pipeline phase if a system value is changed to a value that does not allow the opportunity to pass a lower threshold.
3.138.60.166