IF, THEN, ELSE Not working when combining relevance

I am trying to build a failsafe in to my relevance used to determine the installed version of WebEx. When I look for the presence of the value I want to query it works fine:

Q: exists values “DisplayVersion” of keys whose (value “DisplayName” of it as string as lowercase contains “webex productivity tools”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry
A: True
T: 4.897 ms
I: singular boolean
F: Fingerprintable: true, Path: 0x00000001, Path Sum: 0x00e72528, Bits: 0x80000000, Global Sum: 0x00e72e7f, Seems Unchanged: true

When I ask for that value to be returned it works fine:

Q: ( values “DisplayVersion” of it) of keys whose (value “DisplayName” of it as string as lowercase contains “webex productivity tools”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry as string
A: 2.36.13040.10128
T: 18.006 ms
I: plural string
F: Fingerprintable: true, Path: 0x00000001, Path Sum: 0x00725c57, Bits: 0x80000000, Global Sum: 0x007265ae, Seems Unchanged: true

When I tried to combine them it fails. I assume it has to do with the output types plural string vs singular boolean but I can’t figure how to correct it.

Can anyone provide some context on how to fix this?

Thanks!

Can you post your combined relevance you’re trying to use?

Sure:

IF (exists values “DisplayVersion” of keys whose (value “DisplayName” of it as string as lowercase contains “webex productivity tools”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall”) THEN ( values “DisplayVersion” of it) of keys whose (value “DisplayName” of it as string as lowercase contains “webex productivity tools”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry as string ELSE “Not Detected”

There are multiple places where the condition could bail out. What if there were no answer to keys whose for example?

Also if you used another “it” you could do something like:

(if ( exists values "DisplayVersion" of (keys of it)  whose (value "DisplayName" of it as string as lowercase contains "webex productivity tools") then ( (value "DisplayVersion" of it) of (keys of it ) whose (value "DisplayName" of it as string as lowercase contains "webex productivity tools") ) of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of registry

OR maybe this works for your needs?

(value "DisplayVersion" of it as string | "Not Detected") of keys whose (value "DisplayName" of it as string as lowercase contains "webex productivity tools") of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of registry
1 Like

Thanks for posting Alan, but neither of these seem to evaluate successfully.

What is the error you are getting (doing those from memory as I’m sitting on a Mac right now)

You probably just need an “of registry” on your statements

1 Like

D’oh! Yeah that would help :slight_smile:

1 Like

Perfect. Many thanks!

1 Like

Many thanks AlanM!!!

1 Like

You don’t actually need an IF statement to build in a failsafe. That is what plural relevance does for you automatically.

This is all you need:

unique values of (it as string) of values "DisplayVersion" of keys whose (value "DisplayName" of it as string as lowercase contains "webex productivity tools") of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x64 registries; x32 registries)

Don’t use IF statements at all in this case. If it doesn’t exist, then it will report <none>