How to autocreate RITM once date is expired
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2024 12:10 AM
Hi Team,
How to auto create RITM once date is expired.
Ex:
Date is expired, then automatically needs to create Requested Item.
How to create automatically Requested Item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2024 12:19 AM
hi @Gopal14
To automatically create a Requested Item (RITM) when a certain date is expired, you can use a combination of a scheduled job and a script.
Create a New Scheduled Job:
Run: Select how often you want this job to run (e.g., Daily, Hourly).
Condition: You can set a condition if you only want to check for specific criteria, but typically you will just run the job on a schedule.
Script: write script to create RITM
(function() {
// Define the table where you are checking for expiration dates
var gr = new GlideRecord('your_table_name'); // Replace with your table name
gr.addQuery('expiration_date', '<=', new GlideDateTime()); // Adjust the field name
gr.addQuery('state', '!=', 'closed'); // Optionally check that the state is not closed
gr.query();
while (gr.next()) {
// Create the Requested Item (RITM)
var ritm = new GlideRecord('sc_req_item');
ritm.initialize();
ritm.short_description = 'Auto-generated RITM for ' + gr.getDisplayValue('field_name'); // Adjust as needed
ritm.request = gr.sys_id; // Associate with a request if needed
ritm.u_custom_field = gr.u_custom_field; // Map any other fields as necessary
ritm.insert(); // Insert the RITM
// Optionally, you can log or handle errors
}
})();
i hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.
thank you
rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2024 12:19 AM
Hi @Gopal14
You can do this via Flow designer easily. In Flow designer you can schedule and put the condition.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2024 12:41 AM - edited 09-27-2024 12:42 AM
On this variable I want logged in user name needs to populate. How can I achieve this in flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2024 01:15 AM
Expert @Rajesh Chopade1 already provide the script.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************