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

So than you're query is incorrect. Please fix it.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Can you please help me in this case as in what object can I pass for the button visibility.

Now you are quering the number field (which is NOT a reference), with current.sys_id (which is a reference).

 

So what could you use to query? What would be correct? I don't know, since it's your custom application.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Any luck? Or still help needed?

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

SunilKumar_P
Giga Sage

Hi @Pratiksha Lang1, Can you try calling the script include in the background script by passing the gliderecord object or sys_id and see if its printing any logs?

 

Regards,

Sunil