Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

HI All

basha shaik
Tera Contributor

Hi All,

 

my question is related to workflow if else condition

i have two Fields

1. date field

2.days_count

 

bashashaik_0-1710919803506.png

two days diff is days_count

so 0-5 days goes to Approval user manager

remain days goes to Approval another User

 

Please give  me best code

 

Thanks ADV

 

1 REPLY 1

Krushna R Birla
Kilo Sage

Hi @basha shaik 

 

You can use below script in your workflow script activity,

 

(function execute(inputs, outputs) {
var today = new GlideDateTime(); // Get today's date
var startDate = new GlideDateTime(inputs.date); // Assuming inputs.date is the date field on your form which is Date exception field
var daysDiff = GlideDateTime.subtract(today, startDate).getDayPart();
if (daysDiff >= 0 && daysDiff <= 5) {
// Set approval_group to the manager's group
outputs.approval_group = 'Manager Group';
} else {
// Set approval_group to another group
outputs.approval_group = 'Another Group';
}
})(inputs, outputs);
 
If this solution resolves your query, kindly mark it as the accepted solution and give it a thumbs up.
 
Feel free to connect with me on LinkedIn.
 
Best Regards,
Krushna Birla