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.

UI Action

Nafisa Zaman
Tera Contributor

there are two button on incident form one is strike and second is chase out .
i want this button to  work as when button would be Disabled/Enabled automatically based on Store Opening Times .
i am using this script  -

 

var hiddenStrike1 = Class.create();
hiddenStrike1.prototype = Object.extendsObject(AbstractAjaxProcessor, {
     
checkStoreTiming:function(){
var gr = new GlideDateTime('u_apex_store_timing');
 var currentTime = new GlideDateTime();
var diff = gr.compareTo(currentTime);
if(diff < 0){
      return true;
 }

      else{

      return false;

}
 },
    type: 'hiddenStrike1'
});
2 REPLIES 2

Danish Bhairag2
Tera Sage

Hi @Nafisa Zaman ,

 

How is this script include called?

This is not correct :

var gr = new GlideDateTime('u_apex_store_timing');

 

u_apex_store_timing should be parsed as a variable & it should come in the script include as parameter.

 

In your existing code your passing that value as a string which is wrong.GlideDateTime expects some date & time value.

 

Thanks,

Danish

 

AshishKM
Kilo Patron
Kilo Patron

Hi @Nafisa Zaman,

You can call this function in the condition of UI Action. UI action will visible/hide based on return value of diff from the script. What's issue there if this script is not working as expected, please share more details.

 

diff = 0 // both date/time are equal => return false

diff= 1 // gr datetime is after currentTime => return false

diff = -1 // gr datetime is before currentTime => return true

 

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution