- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2024 02:36 AM
Hello,
I have a requirement to have a record (RITM) automatically generated on the 1st day of January, April, July and October. The triggers in Flow Designer are not that specific and therefore I am wondering if I can use a script, such as the one below, in Flow Designer to specify when the record is created?
var objDate = new GlideDateTime();
var month = objDate.getMonthUTC();
gs.log("Current month - " + month);
if (month == 1 || month == 4 || month == 7 || month == 10 || month == 12)
Note, this script is taken from an attempt at completing this requirement as a Scheduled Job, but the Scheduled Job doesn't generate the RITM as intended. It'd be easier if I could add this script into FD and complete the requirement this way.
Many thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 02:05 AM
Hi @NathanHaywood, Can you try the below steps?
1. Create an Script Action to check the month
(function execute(inputs, outputs) {
var correctMonth = false;
var objDate = new GlideDateTime();
var month = objDate.getMonthUTC();
if (month == 1 || month == 4 || month == 7 || month == 10 || month == 12){
correctMonth = true;
}
outputs.good_to_go = correctMonth;
})(inputs, outputs);
2. Flow steps:
Regards,
Sunil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2024 02:58 AM
Are you getting any error with the scheduled Job ? Also, if you want to continue with the Flow Designer approach then you can set the trigger to Daily and configure a run script action as a first node inside the flow which will check if today's date is the 1st day of Jan and so on. Based on the output of your run script, you can continue further inside the flow to generate the RITM or can terminate the flow.
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 01:45 AM
Thank you Amit. I will give this a go and let you know how it goes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 02:05 AM
Hi @NathanHaywood, Can you try the below steps?
1. Create an Script Action to check the month
(function execute(inputs, outputs) {
var correctMonth = false;
var objDate = new GlideDateTime();
var month = objDate.getMonthUTC();
if (month == 1 || month == 4 || month == 7 || month == 10 || month == 12){
correctMonth = true;
}
outputs.good_to_go = correctMonth;
})(inputs, outputs);
2. Flow steps:
Regards,
Sunil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 02:23 AM
Hi Sunil, thanks for this. What do I need to do in the Output Variables?
I have this, but I can't seem to find it in the Data Pill Picker back in the flow?
Kind regards