Need to change system setting with BigFix Action Script

Greetings,

I’m trying to do something like the following: Based on hostname string, set a value for a system setting called “Patch_Group”.

I’ve already set my relevance clause which does what I want so when a host becomes relevant, I want to execute an ActionScript.

Here’s an example of my ActionScript:

if (computer name) whose (it as string as lowercase matches (regex “^(sm…d[0-9]+)” as lowercase))
setting “Patch_Group”=“1w” on “{now}” for client
endif

I tried the fixlet debugger, action execution and it completes with no errors. I see my relevant host pop up in the BigFix console and I take action on the host. After a few minutes I see that the action finished(it says “Fixed”) but that system setting does not change. Can somebody tell me what I’m doing wrong?
Thanks.

If the part mentioned is in your actionscript then you need to put relevance statements around it like the below. I added the “exists” as you need to have the statement result in a True and the way you had it you’d get a “computer name” string result instead.

if { exists (computer name) whose (it as string as lowercase matches (regex "^(sm...d[0-9]+)" as lowercase)) }

The {} designate relevance substitution. See https://developer.bigfix.com/action-script/guide/substitution.html

You should also never use a "{now}" as the time as that can get you out of order settings. Use "{parameter "action issue date" of action}" instead

Thanks for the reply but I’m still not getting anywhere with this. Using the curly braces just gives me an error:

“Command failed (class OperationNotDefined)”

I’ve been looking around to try to determine what this is actually telling me in the context of what I’m trying to do but no luck yet.

You need to fix your relevance -

q: exists (computer name) whose (it as string as lowercase matches (regex “^(sm…d[0-9]+)” as lowercase))
E: The operator “lowercase” is not defined.

q: exists (computer name) whose (it as string as lowercase contains “lonmd” as lowercase)
A: True
T: 0.207 ms
I: singular boolean

Yeah, I’m not up on my relevance yet… That’s why I came here :wink:

Ultimately, this worked:

if {exists (computer name) whose (it as string as lowercase contains (regex “^(sm…d[0-9]+)”))}
setting “Patch_Group”=“1w” on “{now}” for client
endif

Thanks for the help, everybody.