Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Clone task button in contextual Action menu in dispatcher workspace

Shanti7
Tera Contributor

Hi, 

I would like to create an action item in Contextual Menu of Dispatcher workspace to clone the tasks. May I know how to create it? thank you.

 

 

 

Shanti7_0-1740435245782.png

 

1 REPLY 1

TajuddinM
Tera Contributor

Hello,

There is a script include "DispatcherWorkspaceCalendarHelper" where we can add any customizations to the OOTB menu items, there add the below function:

 

getContextMenuOptions: function(event, startDate, endDate, calendarTimelineView) {
        var options = [{
            id: "dropdownItem_open",
            label: gs.getMessage("Open")
        }];
        // Agent event has "Open" option and "Edit Event" option(if it is non-repeating event)
        if (event.table == "cmn_schedule_span") {
            if (!event["repeat_type"]) {
                if (!this.fsmWfoActive) {
                    options.push({
                        id: "dropdownItem_EditEvent",
                        label: gs.getMessage("Edit Event")
                    });
                    options.push({
                        id: "dropdownItem_DeleteEvent",
                        label: gs.getMessage("Delete Event")
                    });
                } else {
                    if (event["wfo_event_category"] == DispatcherWorkspaceConstants.FSM_WFO_MEETING_CAT_SYS_ID || event['wfo_event_category'] == DispatcherWorkspaceConstants.FSM_WFO_TRAINING_CAT_SYS_ID) {
                        options.push({
                            id: "dropdownItem_EditEvent",
                            label: gs.getMessage("Edit Event")
                        });
                    }
                }
            }
            return {
                "options": options
            };
        }
        if (this.fsmWfoActive) {
            if (event.table == DispatcherWorkspaceConstants.FSM_WFO_TIMEOFF_TABLE) {
                options.push({
                    id: "dropdownItem_EditEvent",
                    label: gs.getMessage("Edit Event")
                });
                options.push({
                    id: "dropdownItem_DeleteEvent",
                    label: gs.getMessage("Delete Event")
                });
                return {
                    "options": options
                };
            }

        }
        if (DispatcherWorkspaceConstants.WM_TASK_STATE_VALUES.ASSIGNED == event['state'] || DispatcherWorkspaceConstants.WM_TASK_STATE_VALUES.ACCEPTED == event['state']) {
            if (this.isCrewPluginActive && event.requires_crew == 1 && event.type != "CrewMemberTask") {
                options.push({
                    id: "dropdownItem_unassign_crew",
                    label: gs.getMessage("Unassign task")
                });
            } else if (event.type || event.type != "CrewMemberTask") {
                options.push({
                    id: "dropdownItem_unassign_wot",
                    label: gs.getMessage("Unassign task")
                });
            }
        }
        if (!this.hideMap) {
            options.push({
                id: "dropdownItem_view_on_map",
                label: gs.getMessage("View on map")
            });
        }
        if (this.isTaskBundlePluginActive && event['is_bundle'] == true)
            options.push({
                id: "dropdownItem_unbundle",
                label: gs.getMessage("Unbundle")
            });
        var isScheduledTask = event['state'] == DispatcherWorkspaceConstants.WM_TASK_STATE_VALUES.SCHEDULED;
        if (isScheduledTask) {
            options.push({
                "id": "dropdownItem_confirm_assignment",
                "label": gs.getMessage("Confirm Assignment")
            });
            options.push({
                id: "dropdownItem_unassign_wot",
                label: gs.getMessage("Unassign task")
            });
        }

        options.push({
            id: "dropdownItem_snapLeft_wot",
            label: DispatcherWorkspaceConstants.SNAPLEFT_TASK
        });

        if (event["locked"])
            options.push({
                id: "dropdownItem_unlock_wot",
                label: gs.getMessage("Unlock")
            });
        else
            options.push({
                id: "dropdownItem_lock_wot",
                label: gs.getMessage("Lock")
            });
        if (this.isOeSfsActive)
            options.push({
                id: "dropdownItem_discuss",
                label: gs.getMessage("Discuss")
            });

        /*
       Add your new menu item
       Clone task
       This if condition will ensure that the menu item will be added to only Work order tasks
        */
        if (event.table == 'wm_task') {

            options.push({
                id: "dropdownItem_clone_task",
                label: gs.getMessage("Clone Task")
            });
}

        return {
            "options": options
        };
    },

 

After this, you will have the custom menu item visible when you right click on any event.


If you found this helpful, mark it as helpful!!
Also, Accept this solution!