Is there a supported way to modify allocation workbench ?

Vladimir Tomov
Giga Contributor

Hello all,

I would like to ask you if there is a supported way to show custom columns (custom fields) in the allocation workbench. The OOB fields are the name of the resource plan, state, the required hours and so on, but we would like to add also several custom columns. In addition if we click on "reset columns" we observe a full clearance of the actual fields and no information is presented. find_real_file.png

1 ACCEPTED SOLUTION

Harsha Lanka
ServiceNow Employee
ServiceNow Employee

Hi,

Resource Grid has an issue with displaying details after you click on 'reset all columns'. It's a known issue that we are planning to fix it in future releases.

1. If you need a workaround for displaying grid details after you click on 'Reset All Columns', please follow the steps below:

  • Run the below script:
    var gr = new GlideRecord('sys_user_preference');
    gr.addQuery('name', 'allocation_grid_columns');
    gr.addQuery('user', '924b0fba4f8f46002da2a90f0310c7b1'); //UserId
    gr.query();
    while(gr.next()){
    var jsonValue = JSON.parse(gr.getValue('value'));
    gs.log(gr.getValue('value'))
    var taskColIndex = jsonValue.itemColumns.indexOf('task');
    if(taskColIndex != -1) {
    jsonValue.itemColumns.splice(taskColIndex, 1);
    }
    
    var nameColIndex = jsonValue.itemColumns.indexOf('name');
    if(nameColIndex != -1) {
    jsonValue.itemColumns.splice(nameColIndex, 1);
    }
    
    gr.value = JSON.stringify(jsonValue);
    gr.update();
    
    }​
  • After that, clear the cache and logout and login again.
  • Issue with displaying details on grid has to be solved.

2. Yes, there is a way to add custom columns to the grid. There is a script include named 'ResourceGridCustomMetadata' in which you can add columns to it. (You can look at 'ResourceGridSeededMetadata' script include OOB and use it as a reference to add columns in 'ResourceGridCustomMetadata'.). See the example below

If you want to add the column under details header of grid

ResourceGridCustomMetadata.LEFT_GROUPED_COLUMNS = [{ requested_by: { column: 'u_requested_by', snDataType: 'reference', valueGetter: 'labelGetter', headerName: gs.getMessage('Requested by') ,columnGroupShow: 'open' } }];


It depends on what columns you want to add for displaying in grid. Please find the attachment for reference.


Thanks,
Harsha Lanka



View solution in original post

9 REPLIES 9

hide: true - This property makes that column hide by default in Grid. You need to check the column from configuration icon(see the image below) to make it visible.

find_real_file.png


columnGroupShow: 'Open' - You can use/see this property only in ResourceGridSeededMetadata.LEFT_GROUPED_COLUMNS or ResourceGridCustomMetadata.LEFT_GROUPED_COLUMNS or ResourceGridCustomMetadata.RIGHT_AGGREGATE_COLUMNS or ResourceGridSeededMetadata.RIGHT_AGGREGATE_COLUMNS.
The columns which were added in the LEFT_GROUPED_COLUMNS list will come under 'Details' header of the grid.

find_real_file.png
The columns which were added in the RIGHT_AGGREGATE_COLUMNS list will come under 'Total' header of the grid. 

find_real_file.png

If you set it 'Open' then you will be able to see that particular column only when expand the 'Details' Column (Like Group/Role, Task, Priority e.t.c in above image).

If you set it 'Close' then you will be able to see that particular column without even expanding the 'Details' Column. (Like State in below image)

find_real_file.png

"snDataType: 'choice' : OOB, we are using this property to handle client side data. You can pass it as a string for custom columns. (Because, finally if we are returning a string value. You can handle a column return value via 'ResourceGridValueFormatter' or 'ResourceGridCustomValueFormatter'). For custom columns, You can use your own Value Getters.

Also, Properties which were prefixed with 'sn' were used to handle client side data OOB.

Hi again,

Thanks for the update

Unfortunately its not the whole story to be able to add custom columns to the workbench.

I created a HI ticket and not even support have any documentation for this which was rather shocking to be honest.

After some time they went back with some info that i share here:
This is an example on how to add task assigned to:

Step 1:

'assigned_to' is a task column (i.e.. resource_plan -> task -> assigned_to) and I think it should only be displayed on task row data of the grid. So we are going to add that column in 'ResourceGridCustomMetadata.TASK_COLUMNS'
- Open the script include 'ResourceGridCustomMetadata' and modify the below line
- ResourceGridCustomMetadata.TASK_COLUMNS = [
{ assigned_to: { column: 'assigned_to', snDataType: 'string',snValueFormatter: 'getAssignedToOfTask', hidden: true}}
];

Step 2: Defining valueFormatter - getAssignedToOfTask

Open the script include 'ResourceGridCustomValueFormatter' and add the below function
ResourceGridCustomValueFormatter.getAssignedToOfTask = function(gr) {
if(gr.instanceOf('task'))
return gr.getDisplayValue('assigned_to');
else 
return '';
};

Step 3: Making 'assigned_to' column visble under the details column group of grid.

- Open the script include 'ResourceGridCustomMetadata' and modify the below line
- ResourceGridCustomMetadata.LEFT_GROUPED_COLUMNS = [
{ assigned_to: { column: 'assigned_to', snDataType: 'string', headerName: gs.getMessage('Assigned To'), columnGroupShow: 'open'}}
];

Step 4:

- Open the script include 'ResourceGridDataService' and modify the line no.19 (maybe 17) as below
- var taskSummary = this.formatRecords(taskRecords, ResourceGridSeededMetadata.TASK_COLUMNS.concat(ResourceGridMetadata.RIGHT_ACTION_COLUMNS), ResourceGridCustomMetadata.TASK_COLUMNS);

This works as it should but Step 4 requires you to customize an OOB script include with the risk of missing future updates when SNC is upgraded.
So all the "empty" custom script is pretty useless unless ALL the script includes are "empty custom".

I have also confirmed that "string" vs "integer" doesnt matter that much else than if Integer is used then it returns 0 instead of 'blank' when "string" is used (tested it with task.order)

Nevertheless - it works but i think theres still work to be done from ServiceNow to make sure that these customizations doesnt impact OOB Allocation workbench

Hi Harsha,

 

Thanks For information 

 

could you please suggest is there any way to restrict visibility of custom fields  to only particular group on allocation workbench please advice

Thanks

tsylte
Tera Contributor

Thanks for sharing the information on this. I used the information from Harsha to add a Reference column in the ResourceGridCustomMetadata script include, and it worked like a charm. (This is in New York.)