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

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



Hello,

Thank you for this valuable information. Couldn’t find anything related to this topic in the docs site. Is there any way to create and apply a filter based on the custom column that is added to the allocation workbench grid? Something like the buttons that filter the resource plans by state P for Planning, R for Requested etc. or the time span filter?

 

Thanks,

Vladimir Mishev

OOB, There is no possibility to apply filter for a custom column.

Hi Harsha

Thanks for sharing.

Do you have more documentation about the script include "ResourceGridCustomMetadata" ?
Im thinking of the properties available when adding custom columns.

In the first example theres "hide: true"

{
    resource_type: {
        column: 'resource_type',
        snDataType: 'choice',
        headerName: gs.getMessage('Resource Type'),
        valueGetter: 'labelGetter',
        hide: true
    }
}

In the 2nd theres "columnGroupShow":

{
    requested_by: {
        column: 'u_requested_by',
        snDataType: 'reference',
        valueGetter: 'labelGetter',
        headerName: gs.getMessage('Requested by'),
        columnGroupShow: 'open'
    }
}

So my question is - is there a list of available properties and the functionality of these different properties?

Thanks in advance!

 

EDIT:

After some more testing column type seems crucial for this to work.
My issue is that its not 1:1 with the definition of field types between backend and Allocation Workbench.

EX:

This will not work even though the field type IS string

{ request_type: { column: 'request_type', snDataType: 'string', headerName: gs.getMessage('Request Type'), valueGetter: 'labelGetter', hide: false } }

This needs to be "snDataType: 'choice' " to work.

When trying to dot.walk there also seems to be issues:

{ order: { column: 'task.order', snDataType: 'integer', valueGetter: 'labelGetter', headerName: gs.getMessage('Order')}

I do not know if its also something about data type of the field but the field on task table is an integer