logo

NJP

How to prevent entities to get inactivated by mistake

Import · Mar 03, 2021 · article

Hi all,

I had few incidents in the past when entities get inactivated by mistake so I decided to leverage our entity management and improve UX to allow them (managers) to receive a popup message before they proceed with inactivation of an entity

Steps:

  1. Mark "Active" as read-only at dictionary level.
  2. Change your scope to "GRC: Profile".
  3. Go to Profile [sn_grc_profile] and create a UI action called "Mark as inactive" with the following conditions:Name: Mark as inactiveAction name: entity_retireForm button: trueShow insert: trueShow update: trueForm style: destructiveList style: destructiveClient: trueOnclick: confirmAndRetireEntity()Condition: gs.getUser().hasRole('sn_grc.manager') && current.active == trueScript:

    ```

    function confirmAndRetireEntity() {

    var gwt = new GwtMessage();

    var title = gwt.getMessage('When a entity is retired, all related risks and controls are retired. Are you sure you want to continue?');

    var modal = new GlideModal("sn_grc_retire_popup", false, 600, 450);

    modal.setTitle(gwt.getMessage('Confirmation'));

    modal.setPreference('sysparm_title', title);

    modal.setPreference('sysparm_sysid', g_form.getUniqueValue());

    modal.setBackdropStatic(true);

    modal.setPreference('focusTrap', true);

    modal.setPreference('action_name', 'entity_retire');

    modal.render();

    return false;

    }

    if (typeof window == 'undefined')

    updateStatus();

    function updateStatus() {

    current.setValue('active', 'false');

    current.update();

    action.setRedirectURL(current);

    }​

    ```

Result:

image

Note:

1. This pop up can be widely used (its generic) but it was originally created for Policies.

2. You need to create another button called "Mark as active" to perform the opposite behavior of this UI action. I gave "entity_enroll" as action name, change condition to run only on inactive records, change function name "confirmAndEnrollEntity()", change line to "current.setValue('active','true')" and thats it.

image

View original source

https://www.servicenow.com/community/grc-articles/how-to-prevent-entities-to-get-inactivated-by-mistake/ta-p/2306890