CSM FSM workspace "assigned to me" UI action

PinkuM
Tera Contributor

I have a requirement to add a confirmation box in the CSM/FSM workspace after selecting multiple records from the list view, before performing any action.
In the list view, we have an "Assigned to Me" UI action visible. When a user selects this confirmation, the "Assigned to Me" UI action should then perform the actual operation.

 

Please assist me this.

 

Thans In advance!

3 REPLIES 3

Naveen20
ServiceNow Employee

Using flow designer

1 — Create the Subflow

Navigate to Flow DesignerNew Subflow

Name: Assign Records to Current User Application: Your scoped app

Inputs:

Name Type
sys_ids String (comma-separated)
table_name String

Add a Script Step:

(function execute(inputs, outputs) {
    var sysIds = inputs.sys_ids.split(',');
    var table = inputs.table_name;
    var userId = gs.getUserID();
    var count = 0;

    for (var i = 0; i < sysIds.length; i++) {
        var gr = new GlideRecord(table);
        if (gr.get(sysIds[i].trim())) {
            gr.setValue('assigned_to', userId);
            gr.update();
            count++;
        }
    }

    outputs.assigned_count = count;
    outputs.success = (count > 0);
})(inputs, outputs);

Outputs:

Name Type
assigned_count Integer
success Boolean

Publish the subflow.


2 — Create the Declarative Action Assignment

Navigate to sys_declarative_action_assignment.listNew

Field Value
Action label Assign to Me
Table sn_customerservice_case (or your target table)
Applicable to List
Required Selection One or more rows selected
Specify client action true

In the client action payload, configure the two-step flow:

{
  "steps": [
    {
      "id": "confirm",
      "type": "CONFIRM",
      "message": "Are you sure you want to assign the selected record(s) to yourself?",
      "confirmButtonLabel": "Yes, Assign to Me",
      "cancelButtonLabel": "Cancel"
    },
    {
      "id": "execute",
      "type": "SUBFLOW",
      "subflow": "global.assign_records_to_current_user",
      "inputs": {
        "sys_ids": "${context.selectedRecords}",
        "table_name": "${context.table}"
      },
      "successMessage": "Records assigned successfully.",
      "refreshList": true
    }
  ]
}

 

PinkuM
Tera Contributor

Hello, I don’t want to assign the selected records. For this purpose, we already have an out‑of‑box (OOB) UI action in Workspace. What I want is to show a popup when multiple records are selected, before those records are assigned to the actual user.

Tanushree Maiti
Kilo Patron

You can try with it. 

 

In your UI action make sure

 

Client: Checked
Workspace Form Button: Checked  //under workspace tab
OnClick: runAssignToMeConfirm()
Condition: current.assigned_to != gs.getUserID() && current.canWrite('assigned_to')  //Change cond as per your requirement

 

Sample script of UI action:

 

function runAssignToMeConfirm() {
var modal = new GlideModal('glide_confirm_standard');
modal.setTitle('Assign to Me');
modal.setPreference('title', 'Are you sure you want to assign this task to yourself?');
modal.setPreference('onPromptComplete', 'confirmAssignToMe');
modal.render();
}

function confirmAssignToMe() {
gsftSubmit(null, g_form.getFormElement(), 'assign_to_me_server'); // 'assign_to_me_server' is the Action Name
}

if (typeof window == 'undefined') {
serverAssignToMe();
}

function serverAssignToMe() {
current.assigned_to = gs.getUserID();
if (current.assignment_group.nil()) {
// Add logic to find group if needed
}
current.update();
gs.addInfoMessage(gs.getMessage('Record assigned to {0}', gs.getUserDisplayName()));
action.setRedirectURL(current);
}

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: