how to make a workspace readonly for users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2024 09:03 AM
Hi Community
I need a help in how to make a SAM or HAM workspaces read only for certain role users in servicenow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2024 09:11 AM
Hi,
Each view has a name, You need to find the name for SAM/HAM workspace view on the table and then run a client script for that view only
To Run client script for a particular view You need to uncheck the Global field and in the View Field Add the name of the view
This is the script that will make all fields read only, club this with your role check and run this
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2024 09:41 AM
Hi @konijetisumanth ,
Please check below link for reference
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2024 01:26 PM
Hi @konijetisumanth,
Thanks to @Community Alums & @Anurag Tripathi for these details, wasn't aware of this.
The solutions mentioned is a great starting point and help to restrict the relevant information in the tables used (e.g. read-only). However, it should also be noted that the entire SAMP module is designed for the standard roles (sam_user, sam_admin, sam_developer, sam_integrator). This is clearly shown by the fact that certain functions/actions check for these roles in the script during execution and these values are "hard coded". It will not be possible to prevent functions in certain parts of the SAMP workspace as soon as a user has the sam_user role (role is necessary to work with the module)
With Xanadu, ServiceNow introduced the following feature for EAM and I'm looking forward to see the same for SAM and HAM - Personalized workspaces for medical and facility industries (servicenow.com)
Best, Dennis
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2024 01:31 PM
Hi @konijetisumanth ,
function onLoad() {
//Type appropriate comment here, and begin script below
var url = top.location.href; // getting the URL Link
var pathname = new URL(url).pathname; // getting the Path workspace : now/risk/, Native :now/nav/ui/.
pathname = pathname.split('/');
var ur = pathname[2];// getting if its a workspace or native
if ( ur == 'nav') {
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
}
}else{
fields = g_form.getEditableFields();
for ( x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], false);
}
}
}
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda