Page 1 of 1

How can I view when a Switch Flow was last used?

Posted: Tue Apr 13, 2021 1:29 pm
by magnussandstrom
Hi, as a Switch admin it sometimes good to know if a flow is still in use, especially when building special flows on request. Is there an easy way to see when a flow was last processed a job (if it's not avalible in Messages)?

Re: How can I view when a Switch Flow was last used?

Posted: Tue Apr 13, 2021 2:00 pm
by jan_suhr
You can set up an database like MySQL and send an HTPP-Request to it (over PHP) and store data that way.
You have the Switch variables [Switch.FlowName] and [Switch.Date:TimeZone="UTC"] that give you the data you need to see when it last was used.

Re: How can I view when a Switch Flow was last used?

Posted: Tue Apr 13, 2021 2:30 pm
by laurentd
Indeed, same idea.
Using apps, you can also log to csv, Google Sheets, …

Re: How can I view when a Switch Flow was last used?

Posted: Tue Apr 13, 2021 2:31 pm
by patej
@jan_suhr's way (or writing directly to db, too) is the best (and only) way currently to do it reliably, but if you don't have that implemented, you can try checking what the flow's the backing folders' modification dates at data root\Switch Server\backing\flow name\automanaged are ;-) – it's certainly not 100 % reliable because someone might have visited the folder manually earlier and made the date change, but if the date is old, then I think you can rely on it showing that the flow hasn't been used in a while...
Image

However, I wonder if it would be a big thing for Enfocus to include it in the Flow details, too, I'm sure many would find it a useful out-of-the-box feature. Actually, I submitted a feature request last September (ENFFR-2560) asking them to include the modification date and user who modified it, to the Designer's Properties pane and Admin portal so this idea would be a useful addition to that :idea: Currently, there is only the Created date in the description field if it's left intact, but having a date from 2013 or 2016 isn't that useful... ;-)
Image

Re: How can I view when a Switch Flow was last used?

Posted: Tue Apr 13, 2021 3:04 pm
by freddyp
Yet another method: if you have the Reporting Module then the processed jobs stay in the database for the number of days specified in the Preferences. You can use a GraphQL query to check how many jobs were processed by all flows during a certain period. Here is a query you can use in the Switch Web Services REST API:
https://www.enfocus.com/manuals/Develop ... ardGraphQL

Code: Select all

{
  getJobCountPerFlow: jobs_hist(groupBy: ["flow"],
                           since: "2021-01-01T00:00:00Z",
                           to: "2021-05-01T00:00:00Z",
                           period: "month" ) {
    jobs {
      group {
        flow
      }
      count
    }
  }
}
If you see that the count on a certain flow is 0 then it means it has not been used during the period specified in the query.

This can of course also be integrated in a web page that lists the result of the query so it is a better user experience.

Re: How can I view when a Switch Flow was last used?

Posted: Wed Apr 14, 2021 9:47 am
by magnussandstrom
patej wrote: Tue Apr 13, 2021 2:31 pm I wonder if it would be a big thing for Enfocus to include it in the Flow details, too, I'm sure many would find it a useful out-of-the-box feature. Actually, I submitted a feature request last September (ENFFR-2560) asking them to include the modification date and user who modified it, to the Designer's Properties pane and Admin portal so this idea would be a useful addition to that :idea: Currently, there is only the Created date in the description field if it's left intact, but having a date from 2013 or 2016 isn't that useful... ;-)
Image
I also vote for the above as a feature request. For now I will just add a connection that writes small textfiles with jobname_timestamp.txt in all my flows.
switch_logs.png
switch_logs.png (71.16 KiB) Viewed 4469 times