Ouch, I know, maybe there is a better way?
I have the same logic that I want to include in a few rules I don't want to duplicate the logic so if it changes down the track I only have one place to update it.
What I was thinking was to have one rule with no triggers (Call it ProcessBlindLogic). This rule would set a global variable (ProcessBlindLogicResult) to True / False.
In each rule that needs to use this logic I can;
- run the ProcessBlindLogic rule.
- Test the global variable ProcessBlindLogicResult. If False exit the rule.
- If True it will execute the rest of the rule.
Assuming that rule A fires and then rule B fires before rule A completes.
Will Rule B wait until Rule A has finished with ProcessBlindLogic rule or will a second instance of ProcessBlindLogic be started for rule B's use?
If when Rule A runs ProcessBlindLogic it turns ProcessBlindLogicResult to True and when Rule B runs, things have changed and turns it to False. Is it possible that Rule B can set it to False before Rule A can set it to True?
I would just like to confrm my understanding that the actions in a rule are syncronous so there is no chance of using the ProcessBlindLogicResult variable before the same rule has has run the ProcessBlindLogic rule?
Any better alternative to this?
With no triggers the rule will never run.
Keep in mind you can clone a rule.
As far as I know, when you invoke one rule's actions from another, the first rule's actions continue on with the next action more or less immediately (so to directly answer your question, no).
One thing you could do to ensure this is use a global variable (or private boolean on the original rule or virtual switch or any other way you can think of to track this). Set that to a specific value (say true or false) before invoking rule B, then have rule B as its last action set that variable to another/the other value. Then, you know for sure, and you can use a "Wait for event: Variable X becomes Y" in the original rule to wait until this happens.
Maybe. Do you know Groovy or think you can learn? (If you know Java, you've got a good start.) Writing a custom app might be easier than writing a bunch of rules. But, of course, Rule Machine exists so you don't need to do this if you don't want to.
The actions will run if called from another rule, which sounds like the goal here.
I will be running this rule from another rule so the actions will run
I hadn't thought to do that. It is a good work around if I need to make calling ProcessBlindLogic syncronous
How would you accomplish this? The only way I see is to have a trigger from a virtual button or such.
Its an option in the rules engine