Pranesh072
Mega Sage
Mega Sage

Hello Everyone,

In this article, I will discuss about the Delete button on List view for Agent Workspace/Portal similar to native.

 

Purpose

OOB delete button is not present on list view because agent workspace have their own List Action buttons for the list view

 

find_real_file.png

 

 

Procedure

 

1.Navigate to Workspace Experience > Actions & Components > List Actions and click New.

find_real_file.png

 

 

 2.On the form, fill in the fields.

 

find_real_file.png

 

 

Action Assignment form
FieldDescription
Action labelName of the list action. like Delete.
Action nameName that describes what you're adding.
Implemented asAction type. Select Server script.
Button typePrimary green button, such as New in the following image. The secondary button is gray.

Primary and secondary buttons

TooltipText that displays when an agent points their mouse at the icon.
DescriptionShort description of this component.
ApplicationApplication that this component applies to. Global means that the component applies to all applications.
WorkspaceWorkspace that this component belongs in, for example, Agent Workspace, ITSM, CSM, and so forth.
TableTable that this component is tied to. When a record from this table is open, this list action appears.
ViewSet of visual configurations. This value is typically Workspace.
ActiveToggle to make the icon for this list action appear.
OrderInteger that governs the placement of this icon in the list of list actions. A lower number means that it is higher in the list. The typical practice is to make these numbers hundreds, for example, 100, 200, 300, and 400, so you can put new icons between existing ones in the future.

 

 

 

 

3. After form submission, Under Related Links, click Advanced view.

 

find_real_file.png

 

 

4. Check the "Record Selection Required" which will ensure that minimum one record is selected  and check the "Requires delete access" field to ensure that user have delete access

 

find_real_file.png

 

 

disabled when no record is selected 

find_real_file.png

 

 

5. Add this script(same script of delete UI Action on native) in the server script section 

find_real_file.png

 
execDelete();

function execDelete() {
    if (!current.isValidRecord()) {
        gs.log("Not deleting invalid record");
        return;
    }

    if (!current.canDelete()) {
        gs.log("Not deleting " + current.sys_id + " because of security constraints");
        gs.addInfoMessage(gs.getMessage('Skipping delete of {0} because of security constraints',current.getDisplayValue()));
        return;
    }

    current.deleteRecord();
    gs.log("Deleted " + current.getDisplayValue() + " (" + current.sys_id + ")" + " from " + current.getTableName());
}
​

 

 

6.On the Confirmations Settings tab, select the Confirmation Required check box if you want to display a pop-up window that asks the agent to confirm the use of this list action.

 

find_real_file.png

 

 

find_real_file.png

 

https://docs.servicenow.com/bundle/paris-servicenow-platform/page/administer/workspace/task/create-a...

Comments
Ashley Snyder1
Giga Guru

Great article Pranesh,

Were you able to get gs.addinfomessage to work on the list view? I tried it but it doesn't seem to work and can't find anything in the community about it.

Pranesh072
Mega Sage
Mega Sage

what you mean by the infomessage? is it on list load or on click the button?

Ashley Snyder1
Giga Guru

In your example script you have the following gs.addInfoMessage

gs.addInfoMessage(gs.getMessage('Skipping delete of {0} because of security constraints',current.getDisplayValue()));

But I noticed list actions do not display informational messages, so I was wondering where this was displaying.

Stefan K_
Tera Expert

Thanks! 

On the same topic, would you know how to enable delete from a related list in agent workspace? 

Unlike in the platform UI, I don't know how to enable selecting records from here and proceed to delete.

find_real_file.png

 

vfind_real_file.png

Pranesh072
Mega Sage
Mega Sage

You can try same steps in Related List actions

 

find_real_file.png

Stefan K_
Tera Expert

Well that was obvious, thanks!

Bastiaan de Zw1
Tera Guru

The related list button worked, but how did you manage to make the records in a related list selectable.

 

find_real_file.png

Bastiaan de Zw1
Tera Guru

Nevermind, needed to check the 'Selection required' checkbox.

Moumita
Tera Contributor

Thank you Pranesh!!

This article is a saviour 🙂

 

Moumita

Saranya16
Giga Contributor

Hi,

On the agent workspace we have multiple list views, For example we have cases.

For that we have views for my group cases, all cases and unassigned cases.

Is it possible to implement the same feature only for the particular view for example unassigned cases.

Ramanath Naraha
Tera Contributor

Hi Pranesh,

Hope this article is still live 😄

I have a quick question on this, I checked the "Record selection required" for the Related List in Agent workspace. 

I have a customized UI action (Client) which triggers a third party integration. How can I reuse the same UI action on the Agent workspace - Related List after selection of the record.

Please let me know.

Thanks in advance..

Regards,

Ram

Version history
Last update:
‎02-19-2021 01:53 AM
Updated by: