Hi folks,
So I have been tasked with moving our Dynamics system over to the unified interface, I am trying to support a lot of javascript based things which I did not design and don't understand that well. I am currently having an extremely frustrating problem with a script that is supposed to pop a warning notification on the contact form if the contact has a value of "Yes" in the field for 'Criminal Record?'. But it just won't work and I cannot see what the problem is.
Here's the script:
function alertCriminal(executionContext) {
var formContext = executionContext.getFormContext();
var frm = formContext.ui.formSelector.getCurrentItem();
var objText = formContext.getAttribute("new_criminalconvictions").getText();
var warningType = "INFO";
var warningMessage = "Student Has Criminal Conviction";
if (frm != null) {
var formLabel = frm.getLabel();
if (formLabel.toUpperCase() == "CONTACT") {
if(objText == "Yes") {
formContext.ui.setFormNotification(warningMessage, warningType);
}
}
}
}
(And yes, I have checked that the execution context is set to be passed correctly in the form configuration)
Whenever I try to load the form I get this error:
TypeError: formContext.getAttribute(...).getText is not a function
I have checked the line it refers to so many times and I cannot say the problem, I've setup the code exactly as it says in the reference:
var objText = formContext.getAttribute("new_criminalconvictions").getText();
Any help would be greatly appreciated as this is making me want to throw my laptop out the window in frustration.