Compare future value in Due date(in Task A) with current Date time and if matches then create Task B
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I need to create Task B in a custom table (In custom app) when either of the following conditions are met:
STC_flag = Yes and Next Activity = Y, OR STC_flag = Yes and the Due Date/Time of Task A equals the current date/time.
Due date holds a future value, Code 1 is to capture that value.
Code1:
var gdt = new GlideDateTime();
return addBusinessDays(gdt,3);
function addBusinessDays(gdt, daysToAdd) {
var count = 0;
while (count < daysToAdd) {
gdt.addDaysLocalTime(1); // move forward one day
// 1 = Monday … 7 = Sunday
var dayOfWeek = gdt.getDayOfWeekLocalTime();
if (dayOfWeek != 6 && dayOfWeek != 7) {
// Not Saturday or Sunday → count it
count++;
}
}
return gdt;
I have created an Action in flow designer to capture current date and time, mention in Code 2:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Instead of ding by flow you can do this in Business rule to check date as well as create new task
var gr = new GlideRecord("task_a');
gr.addQuery('stc_flag', 'Yes');
gr.addQuery('due_date', '<=', new GlideDateTime());
gr.query();
while (gr.next()) {
var child = new GlideRecord('task_b');
child.initialize();
child.parent = gr.sys_id;
child.insert();gr.stc_flag = 'Processed';
gr.update();
}
if this helps you then mark it as help gull and accept solution,
Rgards ,
Aditya