Need help with UI action visibility on multiple conditions

Pratiksha Lang1
Kilo Sage

Need help with UI action visibility on multiple conditions

I have written script include and called that script include in UI action condition. it works fine if I give encoded query in in the below code on line number 6 which I have commented but it is not working in if condition.

 

Script include :

 

var smdrsOlaScoringCompleted = Class.create();
smdrsOlaScoringCompleted.prototype = {
    allowOlaScoring: function(sysid) {
        var inputOla = new GlideRecord('x_amspi_smdrs_app_ola_score');
        inputOla.addQuery('sys_id', sysid);
        //inputOla.addEncodedQuery('score_number.dateONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()^frequency=Daily^score_number.state=2');
        inputOla.query();
        if (inputOla.next()) {

            inputOla.addEncodedQuery('score_number.dateONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()^frequency=Daily^score_number.state=2');
           

            return 'true';
        }



    },

    type: 'smdrsOlaScoringCompleted'
};
 
 
 
UI Action :
 
(new smdrsOlaScoringCompleted().allowOlaScoring(current.sys_id)=='true');
2 REPLIES 2

Anil Lande
Kilo Patron

Hi,

What is your requirement?

When we use GlideRecord we should ass query before gr.query() statment.

var smdrsOlaScoringCompleted = Class.create();
smdrsOlaScoringCompleted.prototype = {
    allowOlaScoring: function(sysid) {
        var inputOla = new GlideRecord('x_amspi_smdrs_app_ola_score');
        inputOla.addQuery('sys_id', sysid);
   //inputOla.addEncodedQuery('frequency=Daily^score_number.dateONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()^frequency=Daily^score_number.state=2');
        inputOla.query();
        if (inputOla.next()) {          
            return 'true';
        }



    },

    type: 'smdrsOlaScoringCompleted'
};

 

Add in encoded query inside if() is not required and it may throw an error.

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

I want to add it in if because I have multiple condition to check in if else loop