How to check if user can Execute a client-callable script include

Sominnown
Tera Contributor

I have a Client-callable script include with ACLs and an Onload client script of catalog item calls GlideAjax.

Users can see my catalog item in their service portal

- If users pass ACL, they can excute it

- But if an user can't pass ACL, a Javascript error message will show up

Sominnown_0-1693209528890.png

Sominnown_1-1693209550752.png

 

Do we have any method to check if user can excute that GlideAjax before execute it? (simular to current.canRead() current.canWrite())

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Sominnown 

nope there is nothing for this.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Sonam Tiwari
Tera Guru

Hi @Sominnown ,

Not sure, if there exists any method to check that. But you can, for sure, check the same permissions that are defined in that ACL. For example, if the ACL will pass, given the user has itil role then you can check that in your client script with hasRole() and show a message. If they have it, go call the script include else show a error message. (Itil role was just an example, you can do further checks per your acl).

Hope that helps.

HI @Sonam Tiwari,


Thanks for your reply.
Currently I am using the same way as you suggest.

But in the case of more complex logic, scripting for example, to check that can cause duplicate code 🤔

Ankur Bawiskar
Tera Patron
Tera Patron

@Sominnown 

nope there is nothing for this.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks for confirming @Ankur Bawiskar