How do call a script include function on UI action Condition

rafas_2703
Tera Guru

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:

rafas_2703_0-1716375220445.png

 

Thank you if you can help!

3 REPLIES 3

Mark Manders
Mega Patron

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

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?

Aish123
Tera Contributor

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.