The Zurich release has arrived! Interested in new features and functionalities? Click here for more

"Assign to me" button on HR Case - agent workspace

miro2
Mega Sage

Hi

I would like to confirm that the "Assign to me" button in the HR Agent Workspace is not added by default by ServiceNow?
Or is it up to the companies and they can add it if they want. I am not sure why the button is not visible in the HR Case workspace view and the agent has to manually assign themselves, whereas it is available in the native UI.

In UX Form Actions (sys_ux_form_action) I don't see 'Assign to me' button for any HR Case table.


I know how to enable it in the UI Action (for HR Case, 'Workspace Form Button' is unchecked). What is the process behind this? Was it configured that way by design?

miro2_0-1705072253967.png

 


If anyone can shed some light on this, I would be grateful.
Thank you

1 ACCEPTED SOLUTION

Sandeep Rajput
Tera Patron
Tera Patron

@miro2 You assumption is correct the "Assign to me" button is not added by default in HR Agent workspace. You need to follow the following steps to make this button visible and function in HR Agent workspace.

 

1. Navigate to UI Actions in the backend. Filter Assign to me button for sn_hr_core_case table.

Screenshot 2024-01-12 at 9.02.11 PM.png

2.Scroll to the bottom and check the workspace related checkboxes, and add the script in the script field.

Screenshot 2024-01-12 at 9.06.08 PM.png

Here is the script for your reference.

function onClick(g_form) {
    assignToMe();

    function assignToMe() {
        g_form.setValue("assigned_to", g_user.userID);
		g_form.submit(g_form.getActionName());
    }
}

 

Here is how the button looks on the workspace.

Screenshot 2024-01-12 at 9.08.21 PM.png

Hope this helps.

View solution in original post

13 REPLIES 13

Hi @Zach3 ,

 

It worked for me.

I marked the UI action as not client and added the below script.

 

current.assigned_to = gs.getUserID();
current.update();
action.setRedirectURL(current);

 

ahefaz1_0-1705705218854.png

 

Please accept solution OR mark helpful.

 

Thanks,

Thanks ahefaz1. Unfortunately, that did not work on our instance. What did work was using the Workspace Client Script from the Service Operations Workspace ITSM Common application's "Assign to me" (8513fcd0773b301027aae297cd5a9968) UI action.

 

For anyone else looking to make it work, these are the updates we made on the "Assign to Me" UI action (24e08b0edb2277805edefcd6f4961944):

  • Set Workspace Form Button to true
  • Set Format for Configurable Workspace to true
  • Set Workspace Client Script to

 

function onClick(g_form) {
    getMessages(["Select Assignment Group", "Cancel", "Assign", "Assignment Group"], onCopy);

    function onCopy(tMsgs) {
        var ga = new GlideAjax("sn_sow_itsm_common.SOWITSMCommonClientUtils");
        ga.addParam("sysparm_name", "getMemberGroups");
        ga.addParam("userSysID", g_user.userID);
        ga.getXMLAnswer(function(response) {
            try {
                answer = JSON.parse(response);
            } catch (e) {
                return;
            }

            if (g_form.isMandatory("assignment_group") && answer.length > 1 && !g_form.getValue('assignment_group')) {
                var choices = [];
                for (var i = 0; i < answer.length; i++) {
                    choices.push({
                        displayValue: answer[i].displayName,
                        value: answer[i].sys_id,
                    });
                }
                g_modal.showFields({
                    title: tMsgs["Select Assignment Group"],
                    cancelTitle: tMsgs["Cancel"],
                    confirmTitle: tMsgs["Assign"],
                    cancelType: "default",
                    size: "md",
                    confirmType: "confirm",
                    fields: [{
                        type: 'choice',
                        name: 'assignment_group',
                        label: tMsgs['Assignment Group'],
                        choices: choices,
                        mandatory: true
                    }],
                }).then(function(fieldValues) {
                    g_form.setValue('assignment_group', fieldValues.updatedFields[0].value);
                    g_form.setValue('assigned_to', g_user.userID);
                    g_form.save();
                });
            } else {
                assignToMeHelper(answer);
            }
        });
    }
}

function assignToMeHelper(answer) {
    if (!g_form.getValue('assignment_group')) {
        var memberGroups = answer;
        if (memberGroups.length == 1)
            g_form.setValue('assignment_group', memberGroups[0].sys_id);
    }
    g_form.setValue('assigned_to', g_user.userID);
    g_form.save();
}​

 

Hi @Zach3 

This also works for me to save HR case on HR agent workspace when agent hits Assign to me button

g_form.setValue('assigned_to', g_user.userID);

    g_form.save()

 

Could you share your previous configuration/script that didn't work.

Hi @miro2 - I tried the script from ahefaz1 listed above:

 

current.assigned_to = gs.getUserID();
current.update();
action.setRedirectURL(current);

 

 

@Zach3 ,

 

Did you mark the UI action as not Client Side?

 

ahefaz1_0-1706736873487.png

 

Thanks,