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.

List control in Workspace

Linda Eju
Tera Contributor

Hi All,

 

I have a requirement to modify the "New" button in a custom workspace related list. I used the list control on the backend to customize the button, so it would only be visible when the related list is empty, unless it is made visible. However, I found out that the list control is not allowed on the workspace. After researching, I discovered that I need to use a declarative action to achieve this. Can you guide me on how to do this?

 

Below is the script for the list control
 
var gr = new GlideRecord('x_g_dnl5_wonder');
    gr.addQuery('parent_manager', parent.sys_id);
    gr.query();

    answer = gr.hasNext();
2 REPLIES 2

IThelen
Tera Contributor

Hey,
to modify the new button on a related list inside the worksspace you have to create a new Action Assignment with the action  model of related list.
Just search for "related list action" inside the navigation menu. "Now Experience Framework" > "Declarative Actions" > "Related List Actions"

There you can create a new one for your table.
You can also simply copy the default button via "insert and stay" and adjust it from there:
<yourinstance>/sys_declarative_action_assignment.do?sys_id=f281016553213300ffa9ddeeff7b122a

To use the standard implementation set these fields:
Action name: create-new-uxf
Implement as: UXF Client Action
Specific client action: Create New Record
Table: <Your Table>


This will overwrite the default new Action.

To edit the conditions you must select the advanced view, via the related link.
Script Condition:

var gr = new GlideRecord('x_g_dnl5_wonder'); gr.addQuery('parent_manager', parent.sys_id); gr.query(); !gr.hasNext();

If you only want to show the button if there are no related records, you need to negate the gr.hasNext().

I would also advice to set the "Required create access" checkbox to true.

Action AssignmentAction Assignment

is_12
Tera Contributor

@IThelen how to give the below script in the script conidtion

Please can you replay

s.info('checking New UI button 1'+parent.cat_item.u_catalog_type);
if (!parent.active) {
    answer = true;
    gs.info('checking New UI button 3'+answer);
}
 else if (parent.cat_item.u_catalog_type == 'CSR') {
    answer = true;
    gs.info('checking New UI button 8'+answer);
}  else if (parent.cat_item.u_catalog_type == 'SSR') {
    answer = false;
    gs.info('checking New UI button 11'+answer);
}