CSV export limit for a particular role (Export to CSV in List Menu)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2022 08:43 AM
Hello,
I need to have a CSV export limit (system properties) for a particular role. The members of this role should have export limit 100,000 and the other members not having this role should apply the default CSV export limit 10,000
Did anyone encountered this before ?
Thanks a lot in advance 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2022 08:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2022 10:06 AM
Hi @Kristiana
You can use a server-side script to check the user's roles and apply the appropriate export limit. Here is an example of how you could do this:
Navigate to the System Properties module in the ServiceNow platform.
Search for the glide.ui.export.csv.limit property, and click on it to open the property record.
In the "Value" field, enter the default CSV export limit that you want to apply for users who do not have the specified role. For example: 10000.
Click the "Save" button to save the property record.
Navigate to the Scripted Rest API module in the ServiceNow platform.
Click the "New" button to create a new scripted REST API.
In the "Name" field, enter a name for the API, such as Export Limit API.
In the "Script" field, enter the following code:
var csvExportLimit = 10000; // Default CSV export limit
// Get the current user's roles
var roles = gs.getUser().getRoles().join(',');
// Check if the user has the required role
if (roles.indexOf('<ROLE>') !== -1) {
// If the user has the required role, set the CSV export limit to 100,000
csvExportLimit = 100000;
}
// Return the CSV export limit
return csvExportLimit;
-
Replace
<ROLE>
with the name of the role that should have a CSV export limit of 100,000. -
In the "Endpoint" field, enter a URL for the API, such as
/api/export_limit
. -
In the "Method" field, select "GET".
-
Click the "Save" button to save the API.
You can then use this API to retrieve the appropriate CSV export limit for the current user. For example, you can call the API from a client script using an AJAX request, and use the returned value to set the CSV export limit for the current user.
You can then use this API to retrieve the appropriate CSV export limit for the current user. For example, you can call the API from a client script using an AJAX request, and use the returned value to set the CSV export limit for the current user.
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2022 05:30 AM
Thanks for proving the solution.
As i am not quite familiar with the client scripts the steps i am performing are as following:
1. I create the new scripted REST API, i add the code in the resources (get HTTP method), script field.
2. Create script include, call the API and set the property limit
3. The script include should be called in the Context Menu = CVS action script?
Please correct me if i am doing anything wrong in the steps
Thanks a lot for your support!
Kristiana