How do call a script include function on UI action Condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2024 03:54 AM
Hi everyone!
I have a script include that I want to call on the condition of my UI action.
The script is the following:
var HRCaseChecker = Class.create();
HRCaseChecker.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
initialize: function() {},
getCondition: function(sys_id) {
var gr = new GlideRecord('sn_hr_core_case');
gr.addQuery('sys_id', sys_id);
gr.query();
if (gr.next()) {
if(gr.state == '18' && gr.topic_category == 'e2b9ac261b39770096ae993d1d4bcb15'){
return true;
}
return false;
}
},
type: 'HRCaseChecker'
});
Basically what I want to achieve is that the UI action only shows the button when the state has the value 18 and the topic category has that sys_id (return true)
The condition I have on my UI Action is the following:
Thank you if you can help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2024 04:33 AM
Why do you use a script include for this? Why not just use current.state and current.topic_category in the condition field?
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2024 06:10 AM
Hi @Mark Manders ,
Just to clarify that I want this button to be visible in a related list, so current is not working unfortunately, so I need to use a script include right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2024 08:40 AM
Hey @rafas_2703 ,
You can call script include in UI Action. In UI action condition field try to apply bellow syntax.
new <scriptIncludeName>().<methodName();
as per your Script Include Name and function (method) name
write - new HRCaseChecker().getCondition();
Please mark the answer correct/helpful accordingly.
Thank You.