End User to be able to search for any Incident number and Customer Visible Notes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2024 07:17 AM - edited 05-31-2024 07:18 AM
Hi,
I got a requirement where in customer needs an End User in ServiceNow to be able to search for any Incident number and Customer Visible Notes through AI Search or in the Service Portal.
By default if the End User is added to the Incident Form's Affected User field, then he will be able to view the Incident but we need to achieve this even without adding him as Affected User.
I had created a read ACL with the below script but it did not work
if (gs.getUser().getRoles().lenght == 0 && current.affected_user!=gs.getUser().getID())
answer=true;
Could anyone please help me how can we achieve this?
Regards,
Sathwik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2024 02:50 AM
@sathwiksnc did you find the solution for the requirement?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @sathwiksnc ,
Try this,
Role check is unnecessary if you only care about end users.
Incorrect comparison:
current.affected_user != gs.getUser().getID()
should be
current.affected_user != gs.getUserID()Placing the ACL:
Must be a Record ACL on incident with operation = read
Must evaluate true only for the incidents you want users to see.Script has to be corrected to
// Allow only if the user has no roles (end user)
// AND we want to allow them to read incidents even if they are not the affected useranswer = true;
- // Allow if user is not an IT user
if (gs.getUser().getRoles().length === 0) {
answer = true;
} else {
answer = false;
} Go to:
System AI → Search → Sources
Edit the Incident search source
Add Customer Visible Notes as an indexed field
Re-index
Without this step, the incident won’t appear even if ACL allows access.
