The CreatorCon Call for Content is officially open! Get started here.

How to Hide a button for few hours.

Abdul333
Tera Contributor

Hello All,

 

I Created a UI Action button called "Send Reminder", if assigned to field is empty for few hours this button will show in the form. So that previous group memebers can see and send Reminder for current assignment group.

 

After Sending Reminder, need to hide the button for next two hours.

So that no one can see/send reminder within 2hours.

can anyone have idea how we can achieve this, please share your inputs.

 

 

@Ankur Bawiskar @Chuck Tomasi @SANDEEP28 @Mark Roethof 

 

 

Thanks,

Abdul

3 REPLIES 3

Moin Kazi
Kilo Sage
Kilo Sage

You can write script include where

1) first you need to check assigned to field is empty.

2) for hiding button next two hour - you require your reminder should trigger through event so you know when the last event was trigger, based on last event trigger time you can add up two hour and return in the script include true, Otherwise false.

3) Next step would be call your script include in your UI Action button condition field. 

 

This way you hide your button for specific time. I hope you got clarity.

@Moin Kazi , yes I created a Event and added that in email notification also.

Abdul333_0-1691859935896.png

 

In Script inlude i written like this,

showRemindersButton: function(sysId) {
var gr = new GlideRecord('sys_email_log');
gr.addEncodedQuery('sys_created_on>javascript:gs.beginningOfLast2Hours()^notification=' + gs.getProperty('pdi.EmailAction.SendReminderNoticationTest.sysId') + '^email.instance=' + sysId);
gr.query();
if (gr.next()) {
return false;
}
return true;
},

Abdul333_1-1691860547496.png

created system property like this.

 

Could you please check and correct me if i'm wrong, because it's not working.

 

 

Thanks,

Abdul

Hello @Abdul333 

 

Below I have created 1 variable Rmdtime which you have to put your reminder mail log created time in place of "sys_created". Then I have added 2  hours over there and compare with current time.

If "diff" object which is comparing 2 dates return -1 which means our current time is higher than which we set in the RmdTime object.

 

See the code below although i didn't tested but you can modify script and try it

 

var RmdTime = new GlideDateTime(sys_created);

 

/* Here sys_created will be your last remainder mail log created time. For finding sys_created time you can Glide Record email log table */

 

var hours = 60*60*2;

RmdTime.addSeconds(hours);

var currentTime = new GlideDateTime();

 

var diff = RmdTime.compareTo(currentTime);

 

// If diff object returns -1, you can return the true in the script include.

if(diff < 0)

return true;

else{

return false;

}

 

Hope this help to you so mark my answer as helpful. still if you have any query please feel free to ask.

 

Regards

Moin kazi