Scenario:
1. Business Process Flow has three stages, based on the active stage lock the fields which are present in the other 2 stages
2. Also keep one section in the form which will be hidden in the initial stage and visible in other 2 stages.
Stage1 contains new_test1 and new_test2 fields
Stage2 Contains new_test3 and new_test4 fields
Stage3 Contains new_test5 and new_test6fields
// Javascript code- Form Onloadevent register two functions
If we want to acess the bpf fileds, the schema name like is
“header_process_fieldname” like – “header_process_new_test1”
one is main function – bpf and another state change. function
//Gives present active stage
var stage = Xrm.Page.data.process.getActiveStage().getName;
//var stage = activeStages.getName();
function bpf() { debugger; var stage = Xrm.Page.data.process.getActiveStage().getName(); //var stage =activeStage.getName(); hiding(stage); section(stage); Xrm.Page.data.process.getSelectedStage(stageChange); Xrm.Page.data.process.addOnStageChange(stageChange); } function stageChange() { var stage = Xrm.Page.data.process.getActiveStage().getName(); //var stage = activeStages.getName(); hiding(stage); section(stage); } function hiding(stage) { var stage1= ["header_process_new_test1","header_process_new_test2"]; var stage2= ["header_process_new_test3","header_process_new_test4"]; var stage3= ["header_process_new_test5","header_process_new_test6"]; switch (stage) { case "Stage1": visible(stage1); Disabled(stage2); Disabled(stage3); break; case "Stage2": visible(stage2); Disabled(stage1); Disabled(stage3); break; case "Stage3": visible(stage3); Disabled(stage1); Disabled(stage2); break; } } //Lock on the BusinessProcess Flow fields function Disabled(stage) { stage.forEach(function(element) { Xrm.Page.getControl(element).setDisabled(true); },); } //Unlock Lock on the BusinessProcess Flow fields function visible(stage) { stage.forEach(function(element) { Xrm.Page.getControl(element).setDisabled(false); },); } //section hiding for initial stage function section(stage) { if(stage=="Stage1") { Xrm.Page.ui.tabs.get("hidetab").sections.get("tab_2_section_1").setVisible(falseXrm.PagXrm.Page.ui.tabs.get("hidetab").sections.get("tab_2_section_1").setVisible(true
0 comments:
Post a Comment
Note: only a member of this blog may post a comment.