Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

End User to be able to search for any Incident number and Customer Visible Notes

sathwiksnc
Tera Contributor

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

2 REPLIES 2

Rashmi Kumari S
Tera Contributor

@sathwiksnc did you find the solution for the requirement?

 

aparnatelu
Tera Contributor

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 user

      answer = 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.