Does anyone know if i can flip the current choices in the dropdown to have "Your teams work" display
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 07:51 AM - edited 05-16-2024 09:04 AM
Hello Devs,
I have been chasing my tail on an issue:
Does anyone know if i can flip the current choices in the dropdown to have "Your teams work" display first?
I have made a copy of the service desk landing page and need to flip the order of the items in the dropdown menu.
I have updated the UX Client script include below by flipping the order in which the choices are called, but the dropdown menu does not change, is there another piece I am missing?
SowIncidentLandingPageUtils:
}
/**
* Returns configuration for work persona dropdown
* {object} helpers
* @return {object}
*/
static async getWorkPersonaConfig(helpers) {
return {
"items": [{
"id": "your_work",
"label": await helpers.translate("Your team's work")
},
{
"id": "your_team_work",
"label": await helpers.translate("Your work")
}
],
"defaultSelected": ["your_team_work"]
}
}
Any help would be greatly appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 08:36 AM - edited 05-16-2024 08:38 AM
Set the 'Sequence' value on the sys_choice records for your table and field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 09:05 AM
Hi @Bert_c1 thank you for the engagement, but i am not finding those values in the sys_choice table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 10:54 AM
Maybe you should post the complete script, I can't find one named "SowIncidentLandingPageUtils" in my instance. And the client script. and maybe steps to test. I see several scritp includes, with names that start with "SowIncident". those that don't end in 'SNC' are present for use to override functions in the SNC version.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 11:08 AM - edited 05-16-2024 11:11 AM
Sure thing @Bert_c1
SowIncidentLandingPageUtilsSNC
function include({
imports
}) {
class ServiceDeskLandingPageUtilsSNC {
/**
* Returns visualization configs
* {object} helpers
* {string} mode
* {number} conditionalRecordCount
* @return object
*/
static async getVisualizationConfig(helpers, mode, conditionalRecordCount=0) {
const evamDef = this.getEvamDef();
const visualizationConfig = [{
"id": "incident_assigned",
"tableName": "incident",
"tableDisplayValue": "Incident",
"myWorkQuery": "active=true^assigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe",
"myTeamQuery": "active=true^assigned_toISNOTEMPTY^assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744",
"listView": mode == "your_work" ? "sow_landing_page_assigned" : "sow_landing_page",
"header": mode == 'your_work' ? await helpers.translate("Incidents assigned to you") : await helpers.translate("Incidents assigned to your team"),
"groupByField": "state",
"evamId": evamDef['incidentEvamDefinitionId'],
"updated_on": "^ORDERBYDESCsys_updated_on",
},
{
"id": "incident_sla",
"tableName": "task_sla",
"tableDisplayValue": "Task SLA",
"myWorkQuery": "task.sys_class_name=incident^task.assigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe^task.active=true^sla.type=SLA^ORsla.type=OLA^active=true^time_left<=1970-01-08 00:00:00",
"myTeamQuery": "task.sys_class_name=incident^task.assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744^task.active=true^sla.type=SLA^ORsla.type=OLA^active=true^time_left<=1970-01-08 00:00:00",
"listView": 'sow_landing_page',
"header": await helpers.translate("Incident SLAs"),
"groupByField": "time_left",
"evamId": evamDef['incidentSlaEvamDefinitionId'],
"updated_on": "^ORDERBYtime_left",
},
{
"id": "unassigned_incidents",
"tableName": "incident",
"tableDisplayValue": "Incident",
"myWorkQuery": "active=true^assigned_toISEMPTY^assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744",
"myTeamQuery": "active=true^assigned_toISEMPTY^assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744",
"listView": mode == "your_work" ? "sow_landing_page_assigned" : "sow_landing_page",
"header": await helpers.translate("Unassigned incidents"),
"groupByField": "priority",
"evamId": evamDef['incidentEvamDefinitionId'],
"updated_on": "^ORDERBYDESCsys_updated_on",
},
{
"id": "catalog_tasks",
"tableName": "sc_task",
"tableDisplayValue": "Catalog Task",
"myWorkQuery": "active=true^assigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe",
"myTeamQuery": "active=true^assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744",
"listView": 'sow_landing_page',
"header": mode == 'your_work' ? await helpers.translate("Catalog tasks assigned to you") : await helpers.translate("Catalog tasks assigned to your team"),
"groupByField": "state",
"evamId": evamDef["catalogTaskEvamDefinitionId"],
"updated_on": "^ORDERBYDESCsys_updated_on",
}
];
if(mode=='your_work' && conditionalRecordCount>0){
const conditionalConfig = await this.getConditionalVisualizationConfig(helpers);
visualizationConfig.push(conditionalConfig);
}
return visualizationConfig;
}
/**
* Returns conditional visualization config
* {object} helpers
* @return object
*/
static async getConditionalVisualizationConfig(helpers) {
const evamDef = this.getEvamDef();
const visualizationConfig = {
"id": "delegated_task",
"tableName": "task",
"tableDisplayValue": "Task",
"myWorkQuery": "active=true^assigned_toDYNAMIC0f63961e5f510100a9ad2572f2b47745^assigned_to.sys_id!=javascript: gs.getUserID()^sys_class_name=incident^ORsys_class_name=sc_task",
"myTeamQuery": "active=true^assigned_toDYNAMIC0f63961e5f510100a9ad2572f2b47745^assigned_to.sys_id!=javascript: gs.getUserID()^sys_class_name=incident^ORsys_class_name=sc_task",
"listView": "sow_landing_page_assigned",
"header": await helpers.translate("Tasks delegated to you"),
"groupByField": "sys_class_name",
"evamId": evamDef['delegatedTaskEvamDefinitionId'],
"updated_on": "^ORDERBYDESCsys_updated_on",
};
return visualizationConfig;
}
/**
* Returns initial visualization config
* {object} helpers
* @return object
*/
static getInitialVisualizationConfig() {
const visualizationConfig = {
"table": "incident",
"elementId": "incident_assigned",
"title": "Incidents assigned to you",
"query": "active=true^assigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe^ORDERBYDESC$AGGREGATE$^ORDERBYDESCsys_updated_on",
"evamId": "01a404e8b7203010e69dbc16de11a93f",
"queryForViewAllRecordCount": "active=true^assigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe^ORDERBYDESC$AGGREGATE$^ORDERBYDESCsys_updated_on",
"tableForViewAllRecordCount": "incident",
"groupByField": "state",
"listView": "sow_landing_page_assigned"
};
return visualizationConfig;
}
/**
* Build visualization card configurations (Donut)
* {object} helpers
* {string} mode
* {number} conditionalRecordCount
* @return object
*/
static async getDonutConfig(helpers, mode, conditionalRecordCount) {
var donutConfig = [];
var visualizationConfig = await this.getVisualizationConfig(helpers, mode, conditionalRecordCount);
for (var i = 0; i < visualizationConfig.length; i++) {
var obj = {};
obj = {
"id": visualizationConfig[i].id,
"header": visualizationConfig[i].header,
"evamId": visualizationConfig[i].evamId,
"updated_on": visualizationConfig[i]["updated_on"],
"listView": visualizationConfig[i].listView,
"datasource": [{
"isDatabaseView": false,
"allowRealTime": true,
"sourceType": "table",
"label": {
"message": visualizationConfig[i].tableDisplayValue
},
"tableOrViewName": visualizationConfig[i].tableName,
"filterQuery": mode == 'your_work' ? visualizationConfig[i].myWorkQuery : visualizationConfig[i].myTeamQuery,
"id": visualizationConfig[i].id
}],
"metric": [{
"dataSource": visualizationConfig[i].id,
"id": visualizationConfig[i].id + "metric",
"aggregateFunction": "COUNT",
"numberFormat": {
"customFormat": false
},
"axisId": "primary"
}],
"groupBy": [{
"maxNumberOfGroups": "ALL",
"numberOfGroupsBasedOn": "NO_OF_GROUP_BASED_ON_PER_METRIC",
"showOthers": false,
"hideZeroValues": true,
"groupBy": [{
"dataSource": visualizationConfig[i].id,
"groupByField": visualizationConfig[i].groupByField,
"isRange": false,
"isPaBucket": false
}]
}]
};
donutConfig.push(obj);
}
return donutConfig;
}
static getEvamDef() {
const evamDef = {
'incidentEvamDefinitionId': '01a404e8b7203010e69dbc16de11a93f',
'incidentSlaEvamDefinitionId': '749b857eb7283010e69dbc16de11a98d',
'catalogTaskEvamDefinitionId': '4a59c876c7323010d7e818b1c7c26083',
'delegatedTaskEvamDefinitionId': '615d205d94df0110f87765e94545da03'
};
return evamDef;
}
/**
* Returns configuration for work persona dropdown
* {object} helpers
* @return {object}
*/
static async getWorkPersonaConfig(helpers) {
return {
"items": [{
"id": "your_work",
"label": await helpers.translate("Your work")
},
{
"id": "your_team_work",
"label": await helpers.translate("Your team's work")
}
],
"defaultSelected": ["your_work"]
}
}
static getRangeObject(query, key) {
var ans = {}
var queryTokens = query.split('^');
for (var index in queryTokens) {
var token = queryTokens[index];
if (token.indexOf(key) == -1)
continue;
token = token.replace('=', '');
if (token.indexOf('<') != -1)
ans.end_value = token.substring(token.indexOf('<') + 1)
else
ans.start_value = token.substring(token.indexOf('>') + 1)
}
return ans;
}
static async getSLAHeader(range, report_ranges, helpers) {
for (var index in report_ranges) {
if (range.end_value == report_ranges[index].upper_value_duration)
return (await helpers.translate("Incident SLA time remaining - {0}", report_ranges[index].label));
}
return (await helpers.translate('Incident SLAs'));
}
static getFieldMap() {
const fieldMap = {
'State': 'state',
'Priority': 'priority',
'Actual time left': 'time_left',
'Task type': 'sys_class_name'
};
return fieldMap;
}
static async fetchTitleForSLA(query, reportRanges, helpers) {
var range = this.getRangeObject(query, 'time_left');
return (await this.getSLAHeader(range, reportRanges, helpers));
}
static async fetchTitle(table, selectedField, groupByField, groupMode = false) {
if(selectedField == undefined){
selectedField = 'all';
}
const labelMap = {
'incident': {
'state': {
'all':'Incidents',
'1': 'New incidents',
'2': 'In Progress incidents',
'3': 'On Hold incidents',
'6': 'Resolved incidents'
},
'priority': {
'all':'Unassigned incidents',
'1': 'P1 unassigned incidents',
'2': 'P2 unassigned incidents',
'3': 'P3 unassigned incidents',
'4': 'P4 unassigned incidents',
'5': 'P5 unassigned incidents'
}
},
'sc_task': {
'state': {
'all':'Catalog tasks',
'-5': 'Pending catalog tasks',
'1': 'Open catalog tasks',
'2': 'Work in progress catalog tasks'
}
},
'task': {
'sys_class_name': {
'sc_task': 'Catalog tasks delegated to you',
'incident': 'Incidents delegated to you'
}
}
};
if((table == 'incident' && groupByField == 'priority') || table == 'task')
return labelMap[table][groupByField][selectedField];
if (groupMode)
return labelMap[table][groupByField][selectedField] + ' assigned to your team';
return labelMap[table][groupByField][selectedField] + ' assigned to you';
}
static async getVisualisationCardConfig(id, helpers, mode, conditionalRecordCount) {
var visualizationConfig = await this.getVisualizationConfig(helpers, mode, conditionalRecordCount);
var currentVizSelection = {};
for (var i = 0; i < visualizationConfig.length; i++) {
if (visualizationConfig[i].id === id) {
currentVizSelection.table = visualizationConfig[i].tableName;
currentVizSelection.query = mode === "your_team_work" ? visualizationConfig[i].myTeamQuery + visualizationConfig[i]["updated_on"] : visualizationConfig[i].myWorkQuery + visualizationConfig[i]["updated_on"];
currentVizSelection.evamId = visualizationConfig[i].evamId;
currentVizSelection.elementId = visualizationConfig[i].id;
currentVizSelection.title = visualizationConfig[i].header;
currentVizSelection.groupByField = visualizationConfig[i].groupByField;
currentVizSelection.listView = visualizationConfig[i].listView;
break;
}
}
return currentVizSelection;
}
static async getVisualisationCardQuery(vizSelection, nameValueMap, helpers, mode, conditionalRecordCount) {
var field = this.getFieldMap()[vizSelection.groupBy];
var value = nameValueMap[field];
var query = '';
var visualizationConfig = await this.getVisualizationConfig(helpers, mode, conditionalRecordCount);
for (var i = 0; i < visualizationConfig.length; i++) {
if (visualizationConfig[i].id === vizSelection.elementId) {
query = mode === "your_team_work" ? visualizationConfig[i].myTeamQuery : visualizationConfig[i].myWorkQuery;
break;
}
}
if (Array.isArray(value)) {
for (let index in value)
query += '^' + field + value[index];
} else {
if (value.includes('='))
query += '^' + field + value;
else
query += '^' + field + '=' + value;
}
return query + visualizationConfig[0]["updated_on"];
}
}
return ServiceDeskLandingPageUtilsSNC;
}
Testing steps:
1. Update the SowIncidentLandingPageUtils script include with the function block below:
/**
* Returns configuration for work persona dropdown
* {object} helpers
* @return {object}
*/
static async getWorkPersonaConfig(helpers) {
return {
"items": [{
"id": "your_team_work",
"label": await helpers.translate("Your team's work")
},
{
"id": "your_work",
"label": await helpers.translate("Your work")
}
],
"defaultSelected": ["your_team_work"]
}
}
2. Navigate to the Service Operations Workspace
3. Check to see if "Your teams work" is displaying first instead of "Your Work"