Hi all,
I am now attempting to have certain tabs, fields, and sections appear and disappear from the page based on a choice in a pick list field. I've gotten it to work when tied directly to the picklist field as the handler. However, when trying to tell the function to also work upon the loading of the form (onLoad handler), it errors out with an "undefined". My guess is that the field hasn't fully finished loading when the script starts executing.
To accommodate the loading of the form's fields prior to running the script, I've tried putting in a timeout based on a while loop that SHOULD wait until the field is no longer null and then proceed with the rest of the script. However, when doing this, the script hangs the browser. Any thoughts?
function ideaPathVisibility()
{
//Wait until the Idea Analysis Path Choice field is populated
var ideaChoicePresent = Xrm.Page.ui.controls.get("new_ideaanalysispath")._control;
while (ideaChoicePresent == null)
{
Xrm.Page.ui.setFormNotification("The path choice is showing as null. Now Waiting.", "INFO", "PathNotify");
//Wait a little bit to accommodate the onload use case
setTimeout
(
function () {
Xrm.Page.ui.clearFormNotification("PathNotify");
}, 3000
);
var ideaChoicePresent = Xrm.Page.ui.controls.get("new_ideaanalysispath")._control;
}
//Obtain the Idea Analysis Path Choice
var ideaChoice = Xrm.Page.getAttribute("new_ideaanalysispath").getText();
//perform the rest of the setting tab visibility below here - this works.
}
Thank you very much for your help!
Best Regards,
Eric
*This post is locked for comments
I have the same question (0)