I need to have a referenced variable read only but receiving an error

abrahams
Kilo Sage

We have a record producer in our Human Resource: Core application.  One of the variables is mapped to subject_person.  I need to make this read only for non HR staff and non leaders.  I thought this would be easy enough with a catalog client script however, I am getting a script error.

 

Script error:  "[SCRIPT:EXEC] Error while running Client Script "Read only subject person": ReferenceError: sn_hr_core is not defined". 

Syntax used:  g_form.setReadOnly('subject_person', true);

 

Why would sn_hr_core not be defined?  

Does anyone know how to work around this error?

1 ACCEPTED SOLUTION

You can't call a Script Include from a Client Script like this, you have to use GlideAjax.  Here's an excellent guide on how to do that.

https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet-updated/ta-p/2... 

 

Also, add an alert on hrStaff - I'm not sure you can/need to use the application prefix when using hasRole.

View solution in original post

5 REPLIES 5

Voona Rohila
Kilo Patron
Kilo Patron

Hi @abrahams 

The script include call in your code is used in server side logic to call SI.

 

If you want to call script include from client script, We have to use GlideAjax

 

https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet/ta-p/2312430

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP