Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Hide UI Action on the basis of certain conditons

Pratiksha Lang1
Kilo Sage

I want to hide UI action on the basis of certain condition. I have written script include and I am calling that script include in UI action condition. It is not going in script include, I am not getting logs as well. Can anyone please help as it is not working as expected.

 

Script include :

 

var smdrsOlaScoringCompleted = Class.create();
smdrsOlaScoringCompleted.prototype = {
    allowOlaScoring: function(current) {
        gs.info("@@@checking my script include");
        var inputOla = new GlideRecord('x_amspi_smdrs_app_input_ola');
        inputOla.addQuery('number', current.sys_id);
        inputOla.addQuery('active', 'true');
        gs.info("@@@checking my script include 1");
        inputOla.query();
        while (inputOla.next()) {
            gs.info("@@@checking my script include 2");
            if (inputOla.frequency == 'Daily') {
                gs.info("@@@checking my script include 3");
                inputOla.addEncodedQuery('sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()^state=1^ORstate=2');
                 return "true";
            }
        }
    },

    type: 'smdrsOlaScoringCompleted'
};
 
 
 
UI Action :
PratikshaLang1_0-1703678557366.png

 

15 REPLIES 15

Rakesh18081
Tera Expert

What I would suggest is add one condition at a time and test if it works fine. Start with the Script Include calling first and then add other conditions one by one.