Create an incident on first working day of the month using flow designer.

mishrarakes
Tera Contributor

I have done this using schedule jobs but how can i achieve this using flow designer, I am not getting option of adding script in flows. can some one help!!

 

8 REPLIES 8

J Siva
Tera Sage

Hi @mishrarakes 
You can create custom script actions to run your script.
Please share more information and if possible share your script from the scheduled job.
Will try to replicate the same with the flow designer.
Regards,
Siva

sure, Here is a script

/***

var now = new GlideDateTime();
var firstDay = new GlideDateTime();
firstDay.setDayOfMonthLocalTime(1);


// 6 == saturday, 7 == sunday  ,1 == monday
while(firstDay.getDayOfWeek() == 6 || firstDay.getDayOfWeek() == 7){
   
    firstDay.addDaysUTC(1);
}

firstDay.setDisplayValue(firstDay.getDate() + " 08:00:00");
var inc = new GlideRecord('incident');
inc.initialize();
inc.short_description = "created Incident for the first working day of the month";
inc.description = "This incident was automatically created on " + firstDay.getDisplayValue();
inc.opened_at = firstDay;
inc.insert();
gs.info("Incident created for " + firstDay.getDisplayValue());
***/

@mishrarakes 

You can achieve this without writing script.
PFB.

 

1. Create a flow with trigger type as "Scheduled -> Monthly -> 1st day at 00:00:00"

2. Create one Schedule (cmn_schedule) as per your required. In this example I took 8-5 weekdays. 

3. Use Wait for a duration of time flow logic to validate the working day by passing the run start Date/time and create the incident once the time is 8AM.

JSiva_0-1742901826736.png

Let me know if you have any queries.
Regards,

Siva

SupriyaWaghmode
Kilo Sage

Hello @mishrarakes ,

 

  • Create the flow which has trigger as schedule and mentioned monthly. Select date  and  time your as per your use case. 
  • Add action as "create record" after trigger and select "table as "incident and all required fields to create. 
  • Please check the attached snap shot to understand. 

 

Flow-Schedule-Month.jpg

 

CreateINC-actionFlow.jpg