Get attempt number for a script


I have some actions that sometimes fails on first attempt but may succeed on second one.
In case fail on first try I want to send email to user X and if failed on second attempt need to send to a different user.
I have set the value of retry attempts as needed and I have a PowerShell script associated to the AfterAction under “Script Editor” which send email.
The question is how can I differentiate between first and second attempt in a script ?
(I don’t want to duplicate actions, use Try-Catch or something similar as it will require to duplicate\wrap 100 actions)


In the Before/After scripts you can use the Action.RetryCount property.


It doesn’t seems to work
I tried it on “InstallShield Project” and “Build VS.Net Solution” actions in the Before\After action and the value is 0 even if it’s not the first attempt.
It seems to be updated correctly on the OnStatusMessage but this doesn’t help me.

I just realised why - we reset the value after the action has finished it’s retries but before the AfterAction event. I have moved the reset so that the value is available in the AfterAction event (which only fires after the retries).

Now it shows the correct number of RetryCount but it doesn’t really help me as the AfterAction is triggered only when the action completely finished so it seems I can’t execute a script after first try failed - please correct me if I’m wrong.

Yes that’s correct. I will have a look at this tomorrow and see if there is something else we can do.


We have added an OnRetry script event to all actions. This event fires Before the Retry (to allow cancelling the retry) - we figured this would be more useful than running after the retry.

The CurrentRetry parameter is the number of the the retry about to happen… unless you set AllowRetry to false (in which case the action will fail).

Note that if you use this script, the project will be incompatible with earlier builds of FB8 (the project will load but the script will never get fired). Normally we try to avoid these sorts of changes but we think this will not get used by many so should relatively safe.

Please let us know how this works out.

I did small test and it seems to work OK
Thanks for your effort.