- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi ,
I'm trying to hide the choice value in state field in the approval tabe base on the source table. I used onload client scrit to hide the option but working .
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
@armanoj
Another approach is to use a Display Business Rule to pass the source table value to the client using g_scratchpad, and then reference that value in your Client Script.
(function executeRule(current, previous) {
g_scratchpad.sourceTable = current.getValue('source_table');
})(current, previous);
Client Scripit
var sourceTable = g_scratchpad.sourceTable;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
it should work fine
share your onLoad script and what debugging did you do?
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday - last edited yesterday
Application : Global
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
@armanoj
Another approach is to use a Display Business Rule to pass the source table value to the client using g_scratchpad, and then reference that value in your Client Script.
(function executeRule(current, previous) {
g_scratchpad.sourceTable = current.getValue('source_table');
})(current, previous);
Client Scripit
var sourceTable = g_scratchpad.sourceTable;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
you won't get the source table using this line
var sourceTable = g_form.getValue('source_table');
So use this approach
1) Display BR on sysapproval_approver table
(function executeRule(current, previous /*null when async*/) {
// Add your code here
g_scratchpad.tableName = current.source_table.toString();
})(current, previous);
2) update your onLoad script with this
function onLoad() {
// Check if approval is for Activity Master
var sourceTable = g_scratchpad.tableName;
if (sourceTable == 'sn_vdr_risk_asmt_activity_masters') {
// Hide specific choices
g_form.removeOption('state', 'cancelled');
g_form.removeOption('state', 'not_requested');
g_form.removeOption('state', 'not_entitled');
g_form.removeOption('state', 'action_complete');
g_form.removeOption('state', 'action_work_in_progress');
g_form.removeOption('state', 'send_back');
g_form.removeOption('state', 'approve_with_caveats');
g_form.removeOption('state', 'request_revision');
}
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader