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.

Restrict Incidents for Service Account

Jake Adams
Tera Contributor

Hi,

 

I have a service account that creates Incidents. Now they want to also Resolve incidents for which I would need to give them Write access on the Incident table. But, also I want to restrict the Service account only to access the Incidents created by them and not beyond that.

 

How can I achieve this?

 

1 REPLY 1

Amit Gujarathi
Giga Sage
Giga Sage

Hi @Jake Adams ,
I trust you are doing great.
You can add the below code in the write ACL , it will resolve your usecase

(function executeRule(current, previous /*null when async*/) {

    // Replace 'your_service_account' with the actual service account user ID
    var serviceAccount = 'your_service_account';

    // Check if the current user is the service account and if they are the creator of the incident
    return gs.getUserID() === serviceAccount && current.opened_by == gs.getUserID();

})(current, previous);

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi