Need to add an exit code statement in action script after a particular part fails

Hi All,

We have customized a fixlet and is responsible updating the BIOS on a HP machine and a part of that fixlet checks to see users presence and its domain controller:-1:

// Info: Display the logged-on user, if any, in the BigFix Client Log

parameter "display_to_user"="{(preceding text of first "|" of it | it) of concatenation "|" of ((if exists domain whose (it as lowercase != computer name as lowercase) of it then domain of it & "\" else "") of user of it & name of it) of logged on users}"

We see different error message when this line fails, the expectation is to add an specific customized exit code which can prove the action failed on the above mentioned line. Please suggest!!

Thanks & Regards.

If I’m understanding the use case, I believe the exit actionscript command should help: https://developer.bigfix.com/action-script/reference/flow-control/exit.html

2 Likes

If I understand, you want the action to terminate with an exit code if that parameter ends up with an empty value (probably because no user is logged on?)

One approach is to modify the Relevance so it’s only relevant when a user is logged on

exists logged on users

Another is to check during the ActionScript. Before even evaluating the parameter you could use one of

Continue if {exists logged on users}

Or

If {not exists logged on users}
    Exit 2
endif

Or, after evaluating the parameter

if {parameter "display_to_user"=""}
    Exit 2
endif
3 Likes

Thanks a lot Jason, that helps!!

Thanks Jason for your support.

We tried to give above parameter but it’s not working.
This action script got failed due to domain connectivity and it’s giving status as “Failed” with Exit code " None".
Can we add Customized Exit Code on this so we can understand how many system got failed due to domain connectivity issue.

Thanks
Ravi Prakash

Can you post the portion of the client log where it’s failing? We’d need more info than this to diagnose where it’s going wrong

Mentioned below is logged file.


Command succeeded parameter “baseFolder” = “__Download/” (action:1934225)
Command succeeded move “__Download/123979146a4b55635f40be9ac6d8ff078b9419be” “__Download/compressedPackageData-202304051223.bftemp” (action:1934225)
Command succeeded extract “compressedPackageData-202304051223.bftemp” “__Download/” (action:1934225)
Command failed (Relevance substitution failed) parameter “display_to_user”="{(preceding text of first “|” of it | it) of concatenation “|” of ((if exists domain whose (it as lowercase != computer name as lowercase) of it then domain of it & “" else “”) of user of it & name of it) of logged on users}” (action:1934225)
At 19:33:38 +0530 -
ActionLogMessage: (action:1934225) ending action

Ok, this helps, I wasn’t sure whether it was throwing a relevance error or just giving an empty result.

I should be able to try some test cases later today or tomorrow, but if you can try before the I expect the approach to be around

If {exists logged on users whose (exists user of it) }
2 Likes

If This action failed on below script then Exit code should be customized. Requesting you to help me.

parameter “display_to_user”="{{(preceding text of first “|” of it | it) of concatenation “|” of ((if exists domain whose (it as lowercase != computer name as lowercase) of it then domain of it & “” else “”) of user of it & name of it) of logged on users}}"

we tried but it’s giving failure with exit code “None”

In a private discussion I continued to work with Ravi on this. We ended up on this ActionScript to detect the condition

// If the user is an AD user but the machine is disconnected from the AD environment this parameter results in a blank string
parameter "display_to_user"="{(preceding text of first "|" of it | it) of concatenation "|" of ((if exists domain whose (it as lowercase != computer name as lowercase) of it then domain of it & "\" else "") of user of it & name of it) of logged on users whose (exists user of it)}"

// Test whether the display_to_user lookup failed and abort the action with an exit code
if {parameter "display_to_user"=""}
  exit 2
endif

// later, use the 'display_to_user' parameter when setting the override for user interface
4 Likes