logic for exceeding time limit

deepika46
Tera Contributor

Hello experts,

 

i have a use case

 

I have a time value example :  var x="30-11-2023 12:35:00"//just a sample value.

 

The day the scheduled job runs which will be gs.nowDateTime() ex var y=" 30-11-2023 12:37:00"

 

If the day the schedule job runs , exceeds the var x like if it passes that value, i need to trigger a mail. Example above will triigger a mail

 

The mail part can be triggered but i am unable to check for the exceeding time limit condition. Can anyone help me to write that logic.

 

Thanks in advance.

1 ACCEPTED SOLUTION

Mohan raj
Mega Sage

Hi @deepika46,

 

you try below logic it. 

var x="30-11-2023 12:35:00"//just a sample value.
var y=" 30-11-2023 12:37:00"

var sampleDate = new GlideDateTime(x);
var scheduledJobRunDate = new GlideDateTime(y);

if(sampleDate < scheduledJobRunDate){
    gs.eventQueue('<event.name>',null,"sys_id of user to whom you need to send email","sys_id of user to whom you need to send email");
}

 

If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.

View solution in original post

1 REPLY 1

Mohan raj
Mega Sage

Hi @deepika46,

 

you try below logic it. 

var x="30-11-2023 12:35:00"//just a sample value.
var y=" 30-11-2023 12:37:00"

var sampleDate = new GlideDateTime(x);
var scheduledJobRunDate = new GlideDateTime(y);

if(sampleDate < scheduledJobRunDate){
    gs.eventQueue('<event.name>',null,"sys_id of user to whom you need to send email","sys_id of user to whom you need to send email");
}

 

If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.