<= condition for today in BR

Poorva Bhawsar
Mega Sage

How to write a <= today condition in a BR.

 

So, last bia approval is a date field. In this BR, i need to check that if last bia approval is not empty and last bia approval is <= today or > today.

 

Is this the correct way to write this for a date field.

if(current.u_last_bia_approval != '' && current.u_last_bia_approval <= 'today'){
        current.setValue('u_bia_state', 'Expired BIA');
8 REPLIES 8

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

You could have a no code solution for this if you split this out in 2/3 BR 

Use condition builder and set value . 

I would recommend that instead of using < in script 

-Anurag

Amit Pandey
Kilo Sage

Hi @Poorva Bhawsar 

 

Pls check the following script-

 

if (current.u_last_bia_approval != '') {
    var lastBiaApproval = new GlideDateTime(current.u_last_bia_approval);
    var today = new GlideDateTime();
    today.setDisplayValue(today.getDate().toString());

    if (lastBiaApproval <= today) {
        current.setValue('u_bia_state', 'Expired BIA');
    } else {
        current.setValue('u_bia_state', 'Valid BIA');
    }
}

 

Regards,

Amit

Here i have 3 conditions:

1. When last bia approval is empty then set bia state as not published.

2. When last bia approval is not empty and last bia approval <= today then set bia state as expired.

3. When last bia approval is not empty and last bia approval > today then set bia state as published.

OlaN
Giga Sage
Giga Sage

Hi,

I agree with @Anurag Tripathi , there is a no-code/low-code way of doing this, create two or three business rules that sets the field depending on the conditions.

Why do you want to script this? Is there something else going on here?