Hi,
I have a OptionSet field on form and i wrote a code to hide a tab on this form if specific item is selected, But if no item is selected, I've got an Error:

function showtab (executionContext){
formContext = executionContext.getFormContext();
var Title = formContext.getAttribute('cos_joblevel').getSelectedOption().text;
if (Title != null){
if (Title == "Apprentice")
{
formContext.ui.tabs.get("tab_evaluationformapprentice").setVisible(true);
}
else
{
formContext.ui.tabs.get("tab_evaluationformapprentice").setVisible(false);
}
}
}
Can anybody help me with this problem?
Thank you in advance!