Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Client script is working in native view but not working in HAM workspace view

vyeturi
Tera Contributor

for this condition= Hide 'yes - rma not required' choice option on under warranty field, if Troubleshoot result = unrepairable

for this scenario we use this code in on change client script
its working native view but not working in workspace view 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var warrantyField = 'u_under_warranty';
    var rmaValue = 'yes - rma not required';

    if (newValue == 'unrepairable') {
        g_form.removeOption(warrantyField, rmaValue);
    } else if (newValue == 'repairable') {
        if (!g_form.getOption(warrantyField, rmaValue)) {
            g_form.addOption(warrantyField, rmaValue, 'Yes RMA Not Required', 1);
        }
    }
}

could you please suggest any recommendation on this then it would be helpful

Regards
Venkatesh

 

2 REPLIES 2

yashkamde
Giga Sage

Hello @vyeturi ,

 

Plz ensure that Clients scripts are set to UI Type = All :

How to configure a client script to run in both platform UI and Workspace 

 

If my response helped mark as helpful and accept the solution.

Ankur Bawiskar
Tera Patron

@vyeturi 

is your client script with UI Type = ALL?

I think this method might not be working in workspace

g_form.getOption(warrantyField, rmaValue)

Did you add alert and see and debug?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader