Hey there,
I wanted to implement a JavaScript that hides/shows form sections based on particular process stage.
This is what I figured out so far:
var stagetabs = new Array(); stagetabs["Projektkonzeption"] = ["Projektkonzeption"]; stagetabs["Partnersuche"] = ["Partnersuche"]; stagetabs["Skizze"] = ["Skizze"]; stagetabs["Antrag"] = ["Antrag"]; stagetabs["Antragsergänzungen"] = ["Antragsergänzungen"]; stagetabs["Zuwendungsbescheid"] = ["Zuwendungsbescheid"]; var stages = null; function Form_OnLoad() { Xrm.Page.data.process.addOnStageSelected(OnStageSelected); Xrm.Page.data.process.addOnStageChange(OnStageChanged); if (Xrm.Page.data.process != null) { stages = Xrm.Page.data.process.getActiveProcess().getStages(); OnStageChanged(); } } function StageTabsLoop(stage, index) { for (var j = 0; j < stagetabs[stage.getName()].length; j++) { Xrm.Page.ui.tabs.get(stagetabs[stage.getName()][j]).setVisible(false); } } function OnStageSelected(state) { var eventAgrs = state.getEventArgs(); var selectedStage = eventAgrs.getStage() stages.forEach(StageTabsLoop); var selectedStage = selectedStage.getName(); for (var i = 0; i < stagetabs[selectedStage].length; i++) { Xrm.Page.ui.tabs.get(stagetabs[selectedStage][i]).setVisible(true); } } function OnStageChanged() { stages.forEach(StageTabsLoop); var activeStage = Xrm.Page.data.process.getActiveStage().getName(); for (var i = 0; i < stagetabs[activeStage].length; i++) { Xrm.Page.ui.tabs.get(stagetabs[activeStage][i]).setVisible(true); } }
But I get this error:
ReferenceError: Form_OnLoad is not defined at eval...
Am I missing something? Code looks fine to me :-D...
TIA
DD
*This post is locked for comments