Check Record creation 90 days ago or not and output record age #2134
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Description:
Hi, before you move through the usecase I would like to let you know that 2 extra commits(Create getCIwithmostActiveInc.js and its README file) from yesterday have come into this PR. Please ignore them as they have already been accepted and merged.
Usecase:
This piece of code can be used to check whether a record was created more than 90 days ago or not.
It returns an output of true/false as well as the actual age (in days) of the record.
Type: Background Script
How it works:
There is a pastDateString variable which can contain a date-time which you received by querying any particular record's sys_created_on field or any other relevant field.
In the actual code I have hard-coded a value to be used as an example.
-There are two gliderecord objects to store the current date as well as past date
-GlideDateTime.subtract() is used to calculate the time difference as a GlideDuration object
-The time duration in milliseconds is converted to days by dividing with 86400000(milliseconds in a day)
-Comparison is done between the results
-The final age of the record and true/false result of the comparison is the output.
[Note: Output may vary according to timezones]
Pull Request Checklist
Overview
Code Quality
Repository Structure Compliance
Core ServiceNow APIs/Server-Side Components/Client-Side Components/Modern Development/Integration/Specialized Areas/Documentation
Restrictions