Updating sc_req_item Due Date based on Onboard Start Date Trouble

jlaps
Kilo Sage

Good afternoon,

For onboarding, if the u_onboard_start_date is AFTER the default due_date, I need to update the due_date to the u_onboard_start_date. I have been trying on insert, which is where I am already doing a bunch of things to pull the start date from variables and get the START DATE to cascade to all RITM and REQ on the order guide. That is set and working.

 

I was not able to update the due date in these INSERT business rules, so am now trying to update via a scheduled job, but still seem unable to pull values for some reason. I assume I am making a stupid user error and am hoping you can point me at it.

var onb = new GlideRecord("sc_req_item");
onb.addEncodedQuery("cat_item=9d89e15f1bf7f910a9e68775cc4bcbb6^sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()");
onb.query();

while (onb.next()){
gdt.setDisplayValue(onb.request.due_date()); //because start date is a date and due date is datetime
gs.info("JAL Onboard RITM: " +onb.number)
gs.info("JAL start date is: ", +onb.u_onboard_start_date.getDisplayValue());
gs.info("JAL due date is: ", +onb.due_date);

//if (gdt > onb.due_date){
//	onb.due_date = gdt;
//	onb.update();
}

The only thing I get from my log statements is the RITM#, the rest is blank. I have tried displayvalue() and without, but I don't seem able to pull these values at all to work with for some reason.

jlaps_0-1713462849443.png

Can you see where I am making the error?

 

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

From a formatting perspective, most everything looks ok except the gdt line which could be causing problems as per your script you did not declare "gdt" to be anything...whether that's for a GlideDateTime object, etc. so perhaps try commenting that out.

 

Additionally you have commas in your two date log statements, please remove the commas.


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

3 REPLIES 3

Allen Andreas
Administrator
Administrator

Hi,

From a formatting perspective, most everything looks ok except the gdt line which could be causing problems as per your script you did not declare "gdt" to be anything...whether that's for a GlideDateTime object, etc. so perhaps try commenting that out.

 

Additionally you have commas in your two date log statements, please remove the commas.


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Copy/Paste fail on the gdt declaration and my mind was skipping past that. Also, thank you on the commas- not sure where that came from. Thank you!

Community Alums
Not applicable

Hi @jlaps ,

Your code is correct but there is small typing error 

var onb = new GlideRecord("sc_req_item");
onb.addEncodedQuery("cat_item=9d89e15f1bf7f910a9e68775cc4bcbb6^sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()");
onb.query();

while (onb.next()){
gdt.setDisplayValue(onb.request.due_date()); //because start date is a date and due date is datetime
gs.info("JAL Onboard RITM: " +onb.number)
gs.info("JAL start date is: " +onb.u_onboard_start_date.getDisplayValue());
gs.info("JAL due date is: " +onb.due_date);

//if (gdt > onb.due_date){
//	onb.due_date = gdt;
//	onb.update();
}

 

gs.info("JAL start date is: ",(extra comma in code) +onb.u_onboard_start_date.getDisplayValue()); ---- Here you adding extra comma(,)
gs.info("JAL due date is: ",(extra comma in code) +onb.due_date);

 

Please mark my answer correct and helpful if this works for you

 

Thanks and Regards 
Sarthak