Due date field on approval table is populating created date

Anupriya_11
Tera Contributor

Hi Team , due date field on approval table  is populating created date , due to which  it is showing Overdue immediately after approval creation, how can we fix it . Can someone help me on this.

Anupriya_11_0-1761760255391.png

 

Thanks,

 

 

3 REPLIES 3

ArpithaMenden
Tera Contributor

Hi @Anupriya_11 

The root cause of your issue is due to

  1. Due Date is not set properly 

    • Business Rule or Flow using current.sys_created_on instead of calculating a future time.

    • In the workflow Approval activity, the “Approval due” field may not be configured.

  2. System behavior
    When the due_date field is empty, ServiceNow sometimes defaults it to the created date in UI calculations — making the record immediately show as “Overdue”.

 

Set via Business Rule on Insert

If approvals are being created outside a workflow (for example, Flow Designer or custom logic), create a Business Rule: on table sys_approval_approver:

When: Before Insert
Condition: current.due_date.nil()
Script:

 

(function executeRule(current, previous /*null when async*/)  {
// Set due date to 2 days after creation if empty
var gdt = new GlideDateTime(); gdt.addDays(2);
current.due_date = gdt;
}
)
(current, previous);

 

This automatically sets a due date 2 days from creation.

 

or 

 

Fix in the Workflow (if there is anything existing)

If you are using a workflow approval activity, open it and check:

  • Go to your Workflow → Approval Action activity.

  • Check the “Approval due” property.

  • Set it to something like javascript: gs.daysAgoStart(-2) → meaning due 2 days from creation.

Example values you can use:

javascript: gs.daysAgoStart(-1) // 1 day from now
javascript: gs.daysAgoStart(-3) // 3 days from now

 
 
If your issue is resolved, please mark my response helpful.
 
Regards,
Arpitha Menden

Sabrina Ethridg
Tera Guru

Depends on how the approval is getting created.  I would start by checking the following:

 

  • Is this happening for every approval or just some of them?
    • if every record has someone modified the default value for the field on that table?
  • if only some, how is the approval record getting created (flow/workflow)?  Is that activity setting a value in the due date field?

jcmings
Mega Sage

How are you creating approvals? Is it OOTB or customized? Are there custom business rules firing on your approval table on insert? What happens if you manually enter a due date?