Sometimes, it is useful to use business process. The customer is forced to make his input in a guided way. In my case, I wanted to show the customer different fields in stage one of the business process, but I wanted to make some fields only mandatory (required), in stage two or further.

01

The first stage is only a chance or idea, so we do not always already know the details like our provision or our field named ‘ZKB…’.

So I started with a webresource and entered the following JavaScript Code:

function Required() {

var activeStage = Xrm.Page.data.process.getActiveStage();

var pipelinephase = Xrm.Page.getAttribute("stepname").getValue();

if (pipelinephase == "1-Chance/Idee") {

 Xrm.Page.getAttribute("abc_corp_zkberloesbeginn").setRequiredLevel("none");

 Xrm.Page.getAttribute("abc_corp_provisionerloesbeginn").setRequiredLevel("none");

 Xrm.Page.getAttribute("abc_corp_umsetzungswahrscheinlichkeit").setRequiredLevel("none");

 Xrm.Page.getAttribute("abc_corp_beauftragungswahrscheinlichkeit").setRequiredLevel("none");

}

else if (pipelinephase != "1-Chance/Idee") {

 Xrm.Page.getAttribute("abc_corp_zkberloesbeginn").setRequiredLevel("required");

 Xrm.Page.getAttribute("abc_corp_provisionerloesbeginn").setRequiredLevel("required");

 Xrm.Page.getAttribute("abc_corp_umsetzungswahrscheinlichkeit").setRequiredLevel("required");

 Xrm.Page.getAttribute("abc_corp_beauftragungswahrscheinlichkeit").setRequiredLevel("required");

}

}

Put the Skript to the Form On Load:

02.JPG

And most important, put the Skript to the Form On Change to Pipelinephase:

01.JPG

 

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 )

Google+ photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Category

Microsoft Dynamics CRM

Tags

, , , , , , , , ,