How to know when ALL the Automation Rules have finished ?

Questions about and code samples for automation process code snippets within Select.
toddsou
Posts: 75
Joined: Wed Jul 25, 2012 9:39 am

How to know when ALL the Automation Rules have finished ?

Post by toddsou »

Hi-

If I have authored and enabled a bunch of Automation Rules, I'd like to programmatically know when the entire set has finished running. As you probably know, they run in random order, so it's not like I can simply add some sort of event notification to the last one and wait to receive that event.

What do you recommend?

I see from the SPAdmin/Automation/Monitoring module that the administrator can monitor when these Automation Rules run, and eventually finish. Is this information also available via SPS SDK? (or, perhaps certain table(s) within the SPS db ?)

Regards,
Todd
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: How to know when ALL the Automation Rules have finished ?

Post by BobRichards »

Followup: Do you want to ensure all automation snippets have run for a specific order or all orders?
Bob Richards, Senior Software Developer, SoftPro
toddsou
Posts: 75
Joined: Wed Jul 25, 2012 9:39 am

Re: How to know when ALL the Automation Rules have finished ?

Post by toddsou »

Specific order.

Thanks.
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: How to know when ALL the Automation Rules have finished ?

Post by BobRichards »

R&D has provided a solution that uses direct access to the Select SQL database. The script aggregates the automation snippet information and in the final "where" clause you provide the integer value of the order identifier (query RootID in pf.Order).

Code: Select all

SELECT TOP (1000)
	O.Number as 'File Number'
	,AI.ExecutionCorrelation as 'Automation Instance'
	,AI.QueuedOn as 'Automation Queued On'
	, AI.LastRunOn as 'Automation Last Run On'
	, AI.Reason as 'Auotmation Message'
	,[Level]
	,[User]
	,[Message]
	FROM [SelectDb].[pf].[OrderLog] as OL
	Left Join pf.[Order] as O on OL.RootID = O.RootID
	Left Join [SelectDb].core.AutomationInstance as AI on O.Guid = AI.ExecutionCorrelation
	Where OL.RootID = '-2147483639'
2022-08-22_10-59-52.png
2022-08-22_10-59-52.png (148.84 KiB) Viewed 8255 times
Bob Richards, Senior Software Developer, SoftPro
toddsou
Posts: 75
Joined: Wed Jul 25, 2012 9:39 am

Re: How to know when ALL the Automation Rules have finished ?

Post by toddsou »

This is great. tyvm.

As you know, the Automation Rules follow a "When this, then That" format.

These logs shown here capture the execution of the "That" part.

Is there also something which captures the execution of the "When" part, as well?

For example, if I defined a Process that only ran for Orders created under the Profile of "Default\ABC Office" (and maybe a few other params), could I find database entries which illustrated that a particular Process met that criteria and when it didn't ?

Thank you.
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: How to know when ALL the Automation Rules have finished ?

Post by BobRichards »

Automation follows a When/If/Then format. When an automation snippet it triggered (the "When"), Select evaluates the "If" criteria and if all are met, it will queue the "Then" activity. We do not store any information about snippets that fail to meet the criteria. The previously described SQL query provides that only information available.

As you can imagine, if we kept information about orders that that didn't meet criteria, the table would grow huge in a short time.
Bob Richards, Senior Software Developer, SoftPro
toddsou
Posts: 75
Joined: Wed Jul 25, 2012 9:39 am

Re: How to know when ALL the Automation Rules have finished ?

Post by toddsou »

Thanks, Bob. That all makes sense.
Select evaluates the "If" criteria and if all are met, it will queue the "Then" activity
Would that be the SelectDb.core.AutomationInstance.QueuedOn column ?

If so, then I think that might be the "tell" that I'm looking for to indicate that a particular Workflow's criteria was met, for a given Order....
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: How to know when ALL the Automation Rules have finished ?

Post by BobRichards »

That is correct.

I just want to make you aware of the [core].[AutomationInstanceView] view in case you ever need more information about the automation snippet.
Bob Richards, Senior Software Developer, SoftPro
toddsou
Posts: 75
Joined: Wed Jul 25, 2012 9:39 am

Re: How to know when ALL the Automation Rules have finished ?

Post by toddsou »

...and what are the available values for core.AutomationInstance.Status ?

Just from observation, I've noted the following so far:
4 = Queued (aka criteria met, but not yet executed...I held the saved Order open)
2 = Running (once the Order was closed )
8 = Done

I think the View you recommended mentioned 128 = canceled ?

Is there another Status value for Failed? any others?

Thank you!
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: How to know when ALL the Automation Rules have finished ?

Post by BobRichards »

See enum ProcessInstanceStatus in namespace SoftPro.Select.Client.Automation (Assembly: SoftPro.Select.Client.dll) for the full list of states.
Bob Richards, Senior Software Developer, SoftPro
Post Reply