Mastering ServiceNow Scripting: Leverage JavaScript APIs to perform client-side and server-side scripting on ServiceNow instances by Andrew Kindred

Mastering ServiceNow Scripting: Leverage JavaScript APIs to perform client-side and server-side scripting on ServiceNow instances by Andrew Kindred

Author:Andrew Kindred [Kindred, Andrew]
Language: eng
Format: epub
Tags: COM000000 - COMPUTERS / General, COM088000 - COMPUTERS / System Administration / General, COM005000 - COMPUTERS / Enterprise Applications / General
Publisher: Packt Publishing
Published: 2018-02-27T00:00:00+00:00


Figure 5.7: UI action to assign an incident to the logged in user

Often with UI actions, the script may not need to be that long to be an effective solution and add value to the user.

Finally, we will take a look at an access control script example. Sometimes it may be necessary to restrict access to a single group and exclude even system admins from seeing records.

We will use the change request table for this example, but obviously, other read access controls exist that would need to be deactivated for our new access control to work. We will only allow the eCAB Approval group access to Software category changes.

Let's take a look at the code:

answer = false;

if (current.category == 'Software') {

if (gs.getUser().isMemberOf('eCAB Approval')) {

answer = 'true';

}

} else {

answer = 'true';

}

Here, we are allowing access if the category is not Software; or, if it is Software, the user must be a member of the eCAB Approval group. We are clearing the Admin overrides checkbox, so even an admin will need to adhere to the rule to gain access. We also add the itil role to the rule to ensure that this role is needed for access to be given.

We can see the rule that we have created in Figure 5.8:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.