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

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

Post by toddsou »

Perfect, thank you.

As mentioned earlier, we can query and identify those AutomationInstance records where their QueuedOn field has been set, thereby indicating they've been placed on the queue for later execution of the "THEN" part of the Process. Now we're questioning the timing of our query. That is, who's to say if there are more records yet to be queued for the targeted Order by the time our query executes? (race condition)

One thought was to re-query until we see one of the records' Status field goes to a value other than 1 (Created) or 4 (Waiting/Idle). This is based on my blind assumption that the execution of any Process's THEN part would not begin until ALL Process' criteria (aka "IF" part) have been evaluated. But maybe that assumption is incorrect? Please confirm.

Alternative guidance appreciated, too.

Regards-
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 »

A snippet will be queued only after all criteria are evaluated and are met. We will not add any item to the queue unless we determine the "When" activity needs to be run.

Since the automation snippets are evaluated one at a time, there is no way to determine if all of the "When" activities have been queued. I'm not sure what a good method would be for your use case since that was not a consideration for this feature. Perhaps you can use the fact that the [core].[AutomationLog].[RecordNumber] value is automatically incremented with each row (IDENTITY(1,1)).
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 »

Will any automation snippets start to run before the system finishes evaluating and perhaps-queueing the remaining automation snippets ?

Or do all criteria evaluations finish before the execution phase beings for those that have been enqueued ?
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 »

I don't believe a behavior is guaranteed. Do not make assumptions in this area since automation snippets run on the most recent version of the order - which might include after some of the snippets execute.
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 »

Hi-

What does core.AutomationInstance.IsTopMost represent ?

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 »

Sorry but since it is not part of a public API, I cannot provide any information about it. We reserve the right to change its functionality or even remove the field in the future without notice.

From what I saw, it doesn't look like a useful flag regarding your topic anyway. ;)
Bob Richards, Senior Software Developer, SoftPro
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 »

I wanted to make sure you were aware of a way to determine if automation snippets have failed by creating a Work List item. I didn't know this existed when I was working with you.

Topic URL: Re: Automatic notification in case of failure.
Bob Richards, Senior Software Developer, SoftPro
Post Reply