- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi everyone,
I’m trying to conditionally hide the "Add Request Change" button based on the project type.
The goal is to make the button visible only for specific project types, and hidden for others depending on predefined conditions.
Thanks,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @mohammadzey,
The buttons such as Add Issue, Add Decision, etc., are being rendered from the Scripted REST Resource(getConfig) available in the sys_ws_operation table.
Within the Scripted REST Resource, the RIDACWorkspace Script Include is being invoked. From this Script Include, the getRIDACConfig() method is responsible for returning the toolbar button configuration.
getRIDACConfig: function(topTaskId, parentTable) {
var ridacColumns = new RIDACColumns().get();
var canCreateRIDACList = [];
var ridacEntitesHasRecordsCount = 0;
const toolBarConfig = this._getToolbarConfig(topTaskId, parentTable);
var parentGr = new GlideRecord(parentTable);
parentGr.get(topTaskId);
if(toolBarConfig && !toolBarConfig.canRead){
return {
status: 'error',
statusCode: '403'
};
}
for(var i=0; i < this.ridacTables.length; i++) {
var table = this.ridacTables[i];
var gr = new GlideRecord(table);
if (table === 'risk') {
gr.addQuery('task', topTaskId);
} else {
gr.addQuery('parent', topTaskId);
}
gr.setLimit(1);
gr.query();
if(gr.getRowCount())
ridacEntitesHasRecordsCount++;
if(gr.canCreate()){
var ridac = {};
ridac.id = table;
ridac.label = gs.getMessage('Add {0}', this.typeMap[table]);
canCreateRIDACList.push(ridac);
}
}
return {
status: 'success',
statusCode: '200',
columns: ridacColumns,
config: this.getConfig(ridacEntitesHasRecordsCount),
toolbar: toolBarConfig,
groupBy: ['ridacType'],
moreActions: gs.getMessage('More actions'),
canCreateRIDACList: canCreateRIDACList,
parentDomain: parentGr.getValue('sys_domain'),
translationMap: this.typeMap
};
}You can enhance the logic as per your requirement inside the method.
If this helps, please mark it as Helpful or accept it as a Solution.
Regards,
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
It has been created from ui builder not as declarative action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @mohammadzey,
The buttons such as Add Issue, Add Decision, etc., are being rendered from the Scripted REST Resource(getConfig) available in the sys_ws_operation table.
Within the Scripted REST Resource, the RIDACWorkspace Script Include is being invoked. From this Script Include, the getRIDACConfig() method is responsible for returning the toolbar button configuration.
getRIDACConfig: function(topTaskId, parentTable) {
var ridacColumns = new RIDACColumns().get();
var canCreateRIDACList = [];
var ridacEntitesHasRecordsCount = 0;
const toolBarConfig = this._getToolbarConfig(topTaskId, parentTable);
var parentGr = new GlideRecord(parentTable);
parentGr.get(topTaskId);
if(toolBarConfig && !toolBarConfig.canRead){
return {
status: 'error',
statusCode: '403'
};
}
for(var i=0; i < this.ridacTables.length; i++) {
var table = this.ridacTables[i];
var gr = new GlideRecord(table);
if (table === 'risk') {
gr.addQuery('task', topTaskId);
} else {
gr.addQuery('parent', topTaskId);
}
gr.setLimit(1);
gr.query();
if(gr.getRowCount())
ridacEntitesHasRecordsCount++;
if(gr.canCreate()){
var ridac = {};
ridac.id = table;
ridac.label = gs.getMessage('Add {0}', this.typeMap[table]);
canCreateRIDACList.push(ridac);
}
}
return {
status: 'success',
statusCode: '200',
columns: ridacColumns,
config: this.getConfig(ridacEntitesHasRecordsCount),
toolbar: toolBarConfig,
groupBy: ['ridacType'],
moreActions: gs.getMessage('More actions'),
canCreateRIDACList: canCreateRIDACList,
parentDomain: parentGr.getValue('sys_domain'),
translationMap: this.typeMap
};
}You can enhance the logic as per your requirement inside the method.
If this helps, please mark it as Helpful or accept it as a Solution.
Regards,
Harish