Unable to make custom variable editor mandatory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2017 06:30 PM
Hi All,
We are having an issue with making fields of a custom variable editor Readonly. could you please help us in resolving it.
Issue:
We have built a custom table(x_ct_request) in our scoped application, this table extends task table.We are using SM variable editor (Global scope) which picks all the variables from the record producers and displays them on (x_ct_request) table. Now we need to make the fields on this variable editor mandatory.
Approach:1:-
I have written an on display Business rule to get all the variable editor fields in g_scratchpad and then tried to make them read only using a client script.
but i am getting an error saying "ReadOnly true not set on field variables.check_status: cross-scope access denied.".
The table on which this business rule and client script are executing are in same application scope i.e. custom application scope.
Approach:2:-
I have written a simple client script statement " g_form.setVariablesReadOnly(true);" bu this doesnt work as well.
When i alert with g_form.getValue('variables.variable_name'); i get the correct value in alert but it doesn't set to readonly I get the same error ("ReadOnly true not set on field variables.check_status: cross-scope access denied.").
Should I create a record in application cross scope access table. If yes should i create it for the formatter table or only for the formatter which is used as variable editor.
Please suggest me a correct approach if i am going wrong.
Waiting for your reply.
Thanks and Regards,
Zabeeulla.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2017 06:51 PM
Please check if this helps: All Variables Readonly Client Script - add roles and editable fields
Application Access Settings - ServiceNow Wiki
How to fix cross-scope access policy : Security restriction issue?
Can you please share you business rule and client script code for quick verification?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2017 07:52 PM
hi Shishir,
I have tried to check the can create and update check boxes for formatter and macro tables so that a cross scope access record gets created . No luck i am still facing the same issue. I get the same error and variables on variable editor are editable.
Regards,
Zabeeulla.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2017 06:55 PM
You might have to do this the dodgy way (not best practice)
https://www.servicenowguru.com/scripting/business-rules-scripting/variables-form-readonly/
However, if you take this route, you won't be able to get your app certified.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2017 07:34 PM
Hi Paul,
We cant try this because the same should reflect on Service portal as well and i dont think "var ve = $('variable_map').up('table');" is supported on Service portal.
I have tried creating a scoped formatter and attacehd a custom macro, but it doesnt get displayed on the form.what could be the reason.
Method:
I have copied existing global ui macro and created a new one in my application scope.
created a new formatter and attached the new macro to it.
It is hidden i only see a seperation line instead of a variable editor.
Regards,
Zabeeulla.