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β
-
Change your application scope to Service Operations Workspace ITSM Applications.
-
In your Classic environment browser tab, go to All > Now Experience Framework > Declarative Actions > Create New Action.
-
Choose List.
-
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
-
-
Right-click on the form header and choose Save.
-
Switch to the Advanced View using the related link under the form.
-
In the Conditions form tab, set the following:
-
Enable Dynamic Evaluation: true (this will show the next two fields)
-
Dynamic Script Condition:
current.active && current.assigned_to.canWrite()
-
Dynamic Record Conditions:
-
Priority | is | 5 - Planning
-
-
-
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();
} -
Right-click on the form header and choose Save.
-
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.
-
Move SOW Actions to the right and Save.
Testβ
Now you'll test to make sure this works.
-
Go to Workspaces > Service Operations Workspace
-
Click the List icon in the left menu.
-
Scroll down and choose Incidents > Open.
-
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.
-
Check an incident with a different priority and see if it becomes grayed out again.
-
Select only a few Priority 5 incidents and click the button. The list should refresh and they'll be assigned to you.