The CreatorCon Call for Content is officially open! Get started here.

Subtract 1 day from populated due date

booher04
Tera Guru

Afternoon community.  I have a need to populate the due date on SCTASK based off of a date field variable(r_3716_distribute_notice) and then subtract 1 day from that date.  I am trying to use a business rule for this but it's not populating correctly.  I am sure I have something wrong in the code.  I've tried many different codes on my own.

var gdt = current.r_3716_distribute_notice;

if (current.r_3716_distribute_notice){
gdt.gs.daysAgo(1);
task.due_date=gdt;
}

Also tried this:

var gdt = current.r_3716_distribute_notice.getGlideObject();

if (current.r_3716_distribute_notice) {

gdt.subtractDays(1);

current.due_date=gdt;

1 ACCEPTED SOLUTION

dvp
Mega Sage

Variables is on RITM.. you need to dot walk to ritm first

Here is the updated script

if(current.request_item.variables.r_3716_distribute_notice != undefined){
	var gdt = new GlideDateTime(current.request_item.variables.r_3716_distribute_notice);
	gdt.addDaysLocalTime(-1);
	current.due_date = gdt;
}

View solution in original post

16 REPLIES 16

dvp
Mega Sage

Variables is on RITM.. you need to dot walk to ritm first

Here is the updated script

if(current.request_item.variables.r_3716_distribute_notice != undefined){
	var gdt = new GlideDateTime(current.request_item.variables.r_3716_distribute_notice);
	gdt.addDaysLocalTime(-1);
	current.due_date = gdt;
}

This actually worked for me once I got the filter correct on the business rule.