Announcements
I am not well versed in Javascript but I am trying to hide/show two different drop down (Choise) fields based on the value of another Choice field. Since I can't use Business Rule on a multi choice field I am stuck with Javascript.
Error message: Cannot read properties of null (reading 'setVisible')
My code
________________________________________________________________________________________________________
function HideFields(executionContext)
{
var formContext = executionContext.getFormContext();
var typeOfServiceProviderValue = formContext.getAttribute("vantage_typeofserviceprovider").getValue();
if (typeOfServiceProviderValue == 218700000)
{
formContext.getControl("vantage_typeofsupportiveservicesneeded").setVisible(true);
}
else
{
formContext.getControl("vantage_typeofsupportiveservicesneeded").setVisible(false);
}
var businesstype = formContext.getAttribute("businesstypecode").getValue();
if (businesstype == 809600001) //Service Provider
{
formContext.getControl("vantage_CountiesServed").setVisible(true);
}
else
{
formContext.getControl("vantage_CountiesServed").setVisible(false);
}
}
Hi VANTAGE,
It seems that you are passing a schema name of the field. You just need to pass the logical name instead of schema name.
Your code should be,
if (businesstype == 809600001) //Service Provider
{
formContext.getControl("vantage_countiesserved").setVisible(true);
}
else
{
formContext.getControl("vantage_countiesserved").setVisible(false);
}
Thanks!
You faced the following error because a wrong logical name was passed for the field (vantage_CountiesServed). Please try again by passing the correct logical name to the setVisible() method.
Hope this helps.
Thanks!
the error is with this
vantage_CountiesServed
you need to write the logical name so is lower case
vantage_countiesserved
André Arnaud de Cal... 291,359 Super User 2024 Season 2
Martin Dráb 230,370 Most Valuable Professional
nmaenpaa 101,156