I need to set the due date of document task as employment start date of user

girishingle
Tera Contributor

Hi,

 

I need to set the due date of the document task as users employment start date. how to achieve this requirement. 

If anyone worked on this requirement, please let me know.

 

Thanks.

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@girishingle 

I don't think anything OOTB is present for this

You can create before insert business rule on sn_doc_task table as follows to set the due date to 5 days after the task creation as follows, this is just an example, please enhance it further

(function executeRule(current, previous /*null when async*/) {
    // Check if due date is not already set
    if (!current.due_date) {
        // Create a GlideDateTime object for the current date
        var dueDate = new GlideDateTime();
        
        // Add 5 days to the current date
        dueDate.addDays(5);
        
        // Set the calculated due date on the task
        current.due_date = dueDate;
    }
})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader