- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 07:58 AM
Hello all,
i have small requirement that , on custom table list view i have created a new view name called "XXX" , so i need to give list edit permission to the users to edit the fields on list view when they are on view called "XXX",
i have used below script but the script is not working , any suggestion that would be great help.
Note - I have created new role to those users.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 09:39 PM
Please try this script below:
/* Restrict to view = “XXX” */
(function () {
var view = 'default';
// When a browser call is in play, get the ?sysparm_view=value
var req = gs.action.getGlideRequest(); // null if no request
if (req) {
var v = req.getParameter('sysparm_view');
if (v) {
view = v;
}
}
// Only allow if the requested view is “XXX”
answer = (view === 'XXX');
})();
Why switch from gs.getSession().getClientData('sysparm_view')?
gs.action.getGlideRequest() is the supported server‑side way to read URL parameters such as sysparm_view.
- getClientData() relies on UI‑only session data... it isn’t always populated when the script runs in background or via API.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 10:10 PM
So list edit should be allowed only for XXX view?
Using list_edit table ACL and checking the view name in that ACL script should help
try this
var url = gs.action.getGlideURI();
if(url.indexOf('XXX') > -1)
answer = true;
else
answer = false;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2025 09:36 AM
Hi @Ankur Bawiskar ,
i have used above code, but it's not working , any alternative solution that would be helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2025 10:38 AM
Can you try this?
/* Restrict to view = “XXX” */
(function () {
var view = 'default';
// When a browser call is in play, get the ?sysparm_view=value
var req = gs.action.getGlideRequest(); // null if no request
if (req) {
var v = req.getParameter('sysparm_view');
if (v) {
view = v;
}
}
// Only allow if the requested view is “XXX”
answer = (view === 'XXX');
})();