HI All

basha shaik
Tera Contributor

HI All,

 

I Have Created one Field that is Due Date Field

bashashaik_0-1710910539948.png

whenever 0-7 goes to user manager Approval

8-infinite days goes to it manager Approval

 

how to Develop this code in workflow use if-else code

 

Please suggest me

 

Thanks ADV

 

 

2 REPLIES 2

Harish KM
Kilo Patron
Kilo Patron

HI @basha shaik you can use if activity to check,

 answer = ifScript();
 
  function ifScript() {
    var dueDate = current.date;
    var checkDays = parseInt(dueDate); //convert to integer
     if (checkDays <= 7) {
        return 'yes';
     }
     return 'no';
  }
Regards
Harish

Deepak Shaerma
Kilo Sage

Hi @basha shaik 

providing the pseudo workflow code for your if-else requirements.

// Calculate the difference in days between the current date and the due date
daysUntilDue = calculateDaysUntilDue(dueDateField)

// Decision-making process
if (daysUntilDue >= 0 and daysUntilDue <= 7) {
    // If the due date is within 0-7 days, seek approval from the user manager
    redirectToUserManagerApproval()
} else if (daysUntilDue >= 😎 {
    // If the due date is 8 days or more away, seek approval from the IT manager
    redirectToITManagerApproval()
} else {
    // Handle cases where the due date might be in the past or invalid
    handleInvalidDueDate()
}


Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help us a lot.
Thanks & Regards 
Deepak Sharma