diff --git a/Specialized Areas/ATF Steps/Validate RITM Due Date/README.md b/Specialized Areas/ATF Steps/Validate RITM Due Date/README.md new file mode 100644 index 0000000000..1f060e175a --- /dev/null +++ b/Specialized Areas/ATF Steps/Validate RITM Due Date/README.md @@ -0,0 +1,9 @@ +## 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: +1) 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. +2) You need a system property called "glide.sc.item.delivery_schedule" that contains the sys id of a record on the cmn_schedule table that will be used for the due date calculation diff --git a/Specialized Areas/ATF Steps/Validate RITM Due Date/atf_ritm_due_date_script.js b/Specialized Areas/ATF Steps/Validate RITM Due Date/atf_ritm_due_date_script.js new file mode 100644 index 0000000000..e00ce5e3ff --- /dev/null +++ b/Specialized Areas/ATF Steps/Validate RITM Due Date/atf_ritm_due_date_script.js @@ -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);