I have a custom task in a custom site that I’ve used for years, and in it there is simple session relevance like this:
if {value of setting “test” of client as integer >=3}
setting “blah”=“yes” on “{now}” for client
endif
even if setting “test” doesn’t exist, this always worked with no session relevance errors, but now I’ve copied the task and am trying to make update to it and now every session relevance is erroring out with “relevance substitution error”. Why is this happening all of a sudden on a new task, when it didn’t do that with my old task?
This looks like client relevance to me, but I think something like the below might work better for you (it shouldn’t error out if the setting does not exist):
if {exists values whose (it as integer >= 3) of settings "test" of client}
Another option would be to use the pipe inspector to handle the error condition for you:
if {(value of setting "test" of client as integer >=3) | false}
That’s right, the pipe inspector was introduced with v8.0. If you have older clients still in the environment, the other approach I have above should work.
I’ll try that, but even a relevance like this is failing (and it’s worked before), where I check the exit code. Obviously that will never successfully evaluate before the action is ran, so that’s why I’m so confused why all of this sudden this is happening.
if {name of operating system as lowercase contains “win”}
waithidden cmd.exe /c command123
continue if {exit code of it = 0}
else if {name of operating system as lowercase contains “linux”}
run sh -c command123
continue if [exit code of it = 0}
endif
One, exit code of it is not valid. The it is a variable so you need exit code of action for this to be valid.
Second, which phase is it failing on? In the check for downloads, the exit code of action may not be understood as an action must be running (not just evaluating the actionscript for downloads)
I use the following to get around that scenario
continue if {exists true whose (if true then (exit code of action = 0) else false)}
Hi, you’re right, i missed the “… of action” when I posted the in the forum thread, but my code did have it in the task.
It’s just strange that I’m getting a relevance substitution error all of the sudden with {exit code of action = 0} in my new task, but an older task that has successful runs used the same exit code relevance substitution without any issues. Can you explain that? It’s like all of the sudden there’s some trigger that forces relevance substitution to error out.
if {(exists service "MSiSCSI" whose (state of it = "Running")) AND (exists value "PowerShellVersion" whose (it as string = "2.0") of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine" of registry) AND (not exists file (value of variable "SystemDrive" of environment & "\supportfiles\iemdata\iscsi_persist.txt")) OR (exists file (value of variable "SystemDrive" of environment & "\supportfiles\iemdata\iscsi_persist.txt") whose (modification time of it > (now-28*day)))}
prefetch e9c48f6dffefa853b9556773fe2a9bac8f74d725 sha1:e9c48f6dffefa853b9556773fe2a9bac8f74d725 size:1823 http://url:52311/Uploads/e9c48f6dffefa853b9556773fe2a9bac8f74d725/iSCSI_persist.ps1.tmp
extract e9c48f6dffefa853b9556773fe2a9bac8f74d725
parameter "PowerShellexe"="{value "Path" of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" of native registry}"
waithidden "{parameter "PowerShellexe"}" -executionpolicy remotesigned __Download\iSCSI_persist.ps1 –evaluate
continue if {exit code of action = 0}
endif
Also if you’re trying to determine which slash to use then you can do one of two things, use different relevance to create a path ( pathname of of of etc ) as the language does it right, or secondarily, Windows is pretty happy about accepting “C:/Windows/System32” etc as a path in this form
hi AlanM, sure, i could do that workaround of allowing the forward slash to be used in Windows, but I need to know why a relevance subsitution error occurs on something as simple as…
(if (name of operating system as lowercase contains "win") then "\" else "/")
…in one task, but works in another task.
It must not just be me because here’s another post with the same issue…
no differences. It’s strange, the old action worked fine, this new action fails , but then I can push the new task again and it seems to work periodically, like the parameter relevance works dependent on a last action run.
no, line 1 is the same in the old action as the new action, and i’m only defining the parameter “slash” once.
The second action has many more if/then logic to it because all the “IF” session relevance statements go into error, which is also different than the original task. I didn’t need to do logic if a file exists in an if {} statement, it just worked.
for example, this IF statement worked in the task without relevance substitution error:
if {value of setting "SMSyncFail" of client as integer >=3}
but with this new task, it would give a relevance substitution error, so I had to convert that line to this:
if {if (exists setting "SMSyncFail" of client) then (if (exists value of setting "SMSyncFail" of client) then (value of setting "SMSyncFail" of client as integer >=3) else true) else false}
It’s always good practice in code to check for the existence of something before trying to access its properties. You can shorten up your new Relevance statement by using a whose/it clause.
exist setting “SMSyncFail” whose (value of it as integer >= 3) of client
i guess one difference in the old task from the new task is the new task has a prefetch/download command in it, Could that be causing the relevance substitution to be evaluated differently?