Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Specialized Areas/ATF Steps/Validate RITM Due Date/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Description:
This script will calculate a due date for a RITM based off of the delivery date of the Catalog Item and validate it matches the actual due date.

## Usage Instructions/Examples:
You can use this in a "Run Server Side Script" ATF test step. This is specfic for RITM's and Catalog Item's with Delivery Times

## Prerequisites/Dependencies:
In your ATF Test Case, you need to create a ATF Test Step that does a Record Query for the RITM record before running this script. The sys id of that Record Query Step is used in the scipt to obtain a GlideRecord of the RITM.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
(function(outputs, steps, params, stepResult, assertEqual) {
// Calculate what the due date should be and compare to the actual due date
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)
var grRITM = new GlideRecord('sc_req_item');
grRITM.get(steps(ritmQuerySysId).first_record);
var calculatedDue; // set up our calculation

var deliveryTime = grRITM.cat_item.delivery_time.dateNumericValue(); // get delivery time in ms

if (deliveryTime) {
var dur = new GlideDuration(deliveryTime);
var scheduleID = gs.getProperty('glide.sc.item.delivery_schedule'); // Property contains the sys id of the schedule used for this date calculation
var schedule = new GlideSchedule(scheduleID);
var gdt = new GlideDateTime(grRITM.opened_at); // due date should be set based on the item's opened timestamp
calculatedDue = schedule.add(gdt, dur);
}

var actualDue = new GlideDateTime(grRITM.due_date);

testAssertion = {
name: "The Due Dates Match!",
shouldbe: calculatedDue,
value: actualDue
};
assertEqual(testAssertion);

})(outputs, steps, params, stepResult, assertEqual);
Loading