Skip to content

Commit f728111

Browse files
authored
Create atf_ritm_due_date_script.js
1 parent 6a91f28 commit f728111

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
(function(outputs, steps, params, stepResult, assertEqual) {
2+
// Calculate what the due date should be and compare to the actual due date
3+
var ritmQuerySysId = ''; // This is the sys id of the Record Query ATF Test Step for the RITM record (NOTE: This needs toe be updated to match your test step)
4+
var grRITM = new GlideRecord('sc_req_item');
5+
grRITM.get(steps(ritmQuerySysId).first_record);
6+
var calculatedDue; // set up our calculation
7+
8+
var deliveryTime = grRITM.cat_item.delivery_time.dateNumericValue(); // get delivery time in ms
9+
10+
if (deliveryTime) {
11+
var dur = new GlideDuration(deliveryTime);
12+
var scheduleID = gs.getProperty('glide.sc.item.delivery_schedule'); // Property contains the sys id of the schedule used for this date calculation
13+
var schedule = new GlideSchedule(scheduleID);
14+
var gdt = new GlideDateTime(grRITM.opened_at); // due date should be set based on the item's opened timestamp
15+
calculatedDue = schedule.add(gdt, dur);
16+
}
17+
18+
var actualDue = new GlideDateTime(grRITM.due_date);
19+
20+
testAssertion = {
21+
name: "The Due Dates Match!",
22+
shouldbe: calculatedDue,
23+
value: actualDue
24+
};
25+
assertEqual(testAssertion);
26+
27+
})(outputs, steps, params, stepResult, assertEqual);

0 commit comments

Comments
 (0)