Detect # of failure retries in action script

I have an ActionScript that I know will fail sometimes. As the action is sent out, I will input the number of times to try and over what time frame for that action. In the script, if some conditions are not met, I exit mid-script and the action is considered a failure. When that happens and the action is on its last retry, I want to kick off a different “IF” condition. Something like:

if {retry number of action >= retry allowed of action}
//do something else here

exit

endif

I know I could be tricky-tricky and write/read a temp file, but hoped there was a better way. There just has to be a way to keep all of this native to action script.

Much appreciated for the help!

I can look it up tomorrow if this is incorrect, but I think you can use
active count of action

1 Like

I see I can get the active count of the action, but how can I get the <RetryCount>3</RetryCount> (from the action xml) info?

I did see this reference page: https://developer.bigfix.com/relevance/reference/action.html

But I’m not finding what I’m looking for.

You may have to manually parse the FXF headers.

Take a look at https://developer.bigfix.com/relevance/reference/fixlet_header.html

Meh… I’ll have to put in an RFE for failure retry count allowed of action or something like that. I’ll work up the action script and post what I find.

OK, I’m close, but I’m getting substituion errors.

//parameter "_fxfFileMail" = "{pathname of client folder of current site}/Action {id of action}.fxf"
//parameter "_fxfFile" = "{pathname of client folder of mailboxsite}/Action {id of action}.fxf"

parameter "_fxfFolder" = "C:\Program Files (x86)\BigFix Enterprise\BES Client\__BESData\mailboxsite"
parameter "_fxfFile" = "Action {id of action}.fxf"

parameter "_retryNum" = "{(it as trimmed string) of following text of first "action-retry-limit: " of lines of file "(parameter "_fxfFile")" of folder "(paramiter "_fxfFolder")"}"

wait cmd /c "echo {id of action} - {active count of action} of {paramiter "_retryNum"} >> c:/test.txt"

I get:
Command succeeded parameter “_fxfFolder” = “C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData\mailboxsite” (action:433942)
Command succeeded parameter “_fxfFile” = “Action 433942.fxf” (action:433942)
Command failed (Relevance substitution failed) parameter “_retryNum” = "{(it as trimmed string) of following text of first “action-retry-limit: " of lines of file “(parameter “_fxfFile”)” of folder “(paramiter “_fxfFolder”)”}” (action:433942)

You have a typo in the relevance :slight_smile:

Try this: https://bigfix.me/fixlet/details/6250

It enumerates most of the things available to you in an action context.

You can get some of what you are looking for.

1 Like

Besides the typ0, this may be a little easier…
(if exist header "action-retry-limit" of it then (value of header "action-retry-limit" of it as string) else "0") of action

3 Likes

That did it @JasonWalker

parameter "_retryNum" = "{(if exist header "action-retry-limit" of it then (value of header "action-retry-limit" of it as string) else "0") of action as integer}"

if { active count of action as integer >= (parameter "_retryNum" as integer + 1) }
	wait cmd /c "echo {id of action} all done! >> c:/test.txt"
else
	wait cmd /c "echo {id of action} - {active count of action} of {parameter "_retryNum"} >> c:/test.txt"
endif
1 Like