Show list banner button based on HR Case state
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2024 05:01 AM
Hi everyone, hope you are doing well!
I am having a problem that I cannot set the visibility on my UI Action correctly. The button should only appear when the state is 18. The problem once again is that the button is working only when the state is 18 but it's appearing for every state. How can I fix this? It is a list banner button.
Condition:
RP.isRelatedList() && RP.getListControl().getControlID() == gs.getProperty('sn_hr_core.Create Child Case') && new HRCaseChecker().getHRCase(parent.sys_id)
Script include:
var HRCaseChecker = Class.create();
HRCaseChecker.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
initialize: function() {},
getHRCase: function(sysId) {
var gr = new GlideRecord('sn_hr_core_case');
gr.addQuery('sys_id', sysId);
gr.query();
if (gr.next()) {
gs.info("estou aqui "+gr.state);
if (gr.state == '18') {
return true;
}
return false;
}
},
type: 'HRCaseChecker'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2024 06:28 AM
are you getting the sysId in your function?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2024 06:30 AM
why not try this in condition itself?
RP.isRelatedList() && RP.getListControl().getControlID() == gs.getProperty('sn_hr_core.Create Child Case') && parent.state == "18"
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2024 07:16 AM
It doesn't work, because I want the current state to be 18. The button is used to create a child case, so that condition won't work, and I can't use current.state because it's a list banner button placed on a related list, so It doesn't "fetch" the current.
Any other ideia @Ankur Bawiskar 🙂 ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2024 07:18 AM
I think that's the limitation of list banner button that it cannot access current object
So this won't work
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader