Skip to main content

Exercise 4: Dynamic List Declarative Action

In this exercise you'll add a new declarative action to a list that is only available when the records selected meet certain conditions.

Goal​

In this exercise, you'll create a list button that allows the user to assign Priority 5 incidents to themselves.

Create the action​

  1. Change your application scope to Service Operations Workspace ITSM Applications.

  2. In your Classic environment browser tab, go to All > Now Experience Framework > Declarative Actions > Create New Action.

  3. Choose List.

  4. Fill out the form that comes up as follows:

    • Action label: Assign to me

    • Action name: acme_assign_to_me

    • Table: Incident [incident]

    • Experience Restricted: true

    • Record Selection Required: true

  5. Right-click on the form header and choose Save.

  6. Switch to the Advanced View using the related link under the form.

  7. In the Conditions form tab, set the following:

    1. Enable Dynamic Evaluation: true (this will show the next two fields)

    2. Dynamic Script Condition:

      current.active && current.assigned_to.canWrite()
    3. Dynamic Record Conditions:

      • Priority | is | 5 - Planning

  8. Set the following Server Script:

    assignToMe();

    function assignToMe() {

    if (!current.active || !current.assigned_to.canWrite()) {
    gs.addErrorMessage(gs.getMessage('{0}, You do not have permission to update assigned to', [current.number]));
    return;
    }

    current.assigned_to = gs.getUserID();
    current.update();
    }
  9. Right-click on the form header and choose Save.

  10. Now, since you chose Experience Restricted is true, you need to associate this action with SOW. Scroll down to the Action Configuration Related List and choose Edit.

  11. Move SOW Actions to the right and Save.

Test​

Now you'll test to make sure this works.

  1. Go to Workspaces > Service Operations Workspace

  2. Click the List icon in the left menu.

  3. Scroll down and choose Incidents > Open.

  4. You should see your new ACME Assign to me button grayed out in the action bar. Select the checkbox next to a Priority 5 incident and you should see the button become selectable.

  5. Check an incident with a different priority and see if it becomes grayed out again.

  6. Select only a few Priority 5 incidents and click the button. The list should refresh and they'll be assigned to you.