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.

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:

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

Like this:
Like Loading...
Related