Help with relevance expression in relevance substitution

We have a CSV file that contains a list of MAC Addresses and other data that we would like to retrieve and set as BES Client Properties. I have most of it working but I could use some help (and a sanity check) on the “Parameter for Email Address matching with parameter of MacAddress” section.

Goals:

  • get a MAC Address and filter out VMNET bridges
  • matching line in CVS against a MAC Address
  • store values as a parameter
  • set as client property

CSV File:

"A1-BC-23-45-D6-78","FirstName","LastName","FirstName.LastName@email.com","ID1Number","CompName","ID2Number","DeptName","UserName","TRUE","2015-11-02 08:06:27"

Parameter for MAC Address:

// Get MAC Address and filter out VMNET bridges
parameter "MacAddress"="{ (( mac address of it ) of adapters whose ( loopback of it = false AND address of it != "0.0.0.0" AND mac address of it as string does not start with "00-50-56-c0-00") of network) }"

Parameter for Email Address matching from known MAC Address

// Get Email Address using static Mac Address with static MAC Address
parameter "Email"="{ tuple string item 3 of (concatenation ", " of (substrings separated by "%22,%22" of (lines of file "data.csv" of (folder "C:\Users\username\Downloads\New folder\")) whose (it as string starts with ("%22A1-BC-23-45-D6-78%22,")))) }"

Parameter for Email Address matching with parameter of MacAddress
Not sure how to use escape brackets for relevance here and add the quotations to the parameter of MacAddress to match what’s in the CSV

// Attempt with Relevance substitution and not sure how to percent-encoding for a quotation mark on a parameter 
parameter "Email"="{ tuple string item 3 of (concatenation ", " of (substrings separated by "%22,%22" of (lines of file "data.csv" of (folder "C:\Users\username\Downloads\New folder\")) whose (it as string starts with ( "{{parameter "MacAddress}")" )))) }"

Set client property

setting "Email_Address"="{parameter "Email" of action}" on "{parameter "action issue date" of action}" for client

This should be closer:

parameter "Email"="{ tuple string item 3 of (concatenation ", " of (substrings separated by "%22,%22" of (lines of file "data.csv" of (folder "C:\Users\username\Downloads\New folder\")) whose (it as string starts with ( parameter "MacAddress" )))) }"

Also, I wouldn’t download the file here in production:

1 Like

In fixlet debugger, I get an error: Command failed (Relevance clauses must be surrounded by { and } guards.)

Is the parameter “MacAddress” not translating?

I think @jgstew’s response is correct. I’ll point out a couple of differences that he’s made by quoting your original action script:

parameter "Email"="{ tuple string item 3 of (concatenation ", " of (substrings separated by "%22,%22" of (lines of file "data.csv" of (folder "C:\Users\username\Downloads\New folder\")) whose (it as string starts with ( "{{parameter "MacAddress}")" )))) }"

You are already within a relevance substitution when you reference the MacAddress parameter, so you don’t need to have additional curly brackets around it. Instead of "{{parameter "MacAddress}", simply use starts with ( parameter "MacAddress" ). In any case, you also tried to close the curly bracket inside the quoted string “MacAddress}”.

Have you tried @jgstew’s version yet?

Looking again at the original, the source file contains quotes around the MAC address field in the CSV right?

So you’ll need to include the quotes in the string matching, ie

starts with ("%22" &  parameter "MacAddress" & "%22")
1 Like

Can you tell which line has the error message? The error you are getting has to do with too many or not enough {} in the actionscript.

Try this also:

parameter "Email"="{ tuple string item 3 of (concatenation ", " of (substrings separated by "%22,%22" of (lines of file "data.csv" of (folder "C:\Users\username\Downloads\New folder\")) whose (it as string contains ( parameter "MacAddress" )))) }"

The MacAddress parameter doesn’t seem to be passing to the email parameter

parameter "MacAddress"="{ (( mac address of it ) of adapters whose ( loopback of it = false AND address of it != "0.0.0.0" AND mac address of it as string does not start with "00-50-56-c0-00") of network) }"

parameter "Email"="{ tuple string item 3 of (concatenation ", " of (substrings separated by "%22,%22" of (lines of file "data.csv" of (folder "C:\Users\username\Downloads\New folder\")) whose (it as string contains ( parameter "MacAddress" )))) }"

Here’s the error message:

Evaluation failed. (Relevance clauses must be surrounded by { and } guards.). Line 5.

STATUS: Running action…
Command succeeded parameter “MacAddress”=“A1-BC-23-45-D6-78”
Command failed (Relevance substitution failed) parameter “Email”="{ tuple string item 3 of (concatenation “, " of (substrings separated by “%22,%22” of (lines of file “data.csv” of (folder “C:\Users\username\Downloads\New folder")) whose (it as string contains ( parameter “MacAddress” )))) }”
Command failed (Relevance clauses must be surrounded by { and } guards.) parameter “Email”=”{ tuple string item 3 of (concatenation ", " of (substrings separated by “%22,%22” of (lines of file “data.csv” of (folder “C:\Users\username\Downloads\New folder")) whose (it as string contains ( parameter “MacAddress” )))) }”

— Result —
Evaluation failed!

1 Like

I’m getting the same error (“Relevance clauses must be surrounded by { and } guards.”) with the following but don’t understand why…

wait cmd /k {if (not exists folder "<pathname1>") then ("copy "<pathname>\*.*" "<pathname2>" /Y") else "notepad.exe"}

If I double the { (which I’m %99.999 sure I don’t need in this case) cmd launches but I get:
’{if’ is not recognized as an internal or external command,
operable program or batch file.

This successfully copies all files in the source folder to the existing destination:
wait cmd /k copy "<pathname1>\*.*" "<pathname2>" /Y

Can someone please lend me some insight?

Thank you

Looks like a misleading error, but at least one problem you’ll have is around the use of doublequotes.

("copy "<pathname>\*.*" "<pathname2>" /Y")

The interpreter would not be able to interpret where the quoted strings are. To embed a literal doublequote as part of your string, you need to percent-encode the ascii value (in this case, %22 for doublequote). Try

("copy %22<pathname>\*.*%22 %22<pathname2>%22 /Y")

1 Like

Thanks again Jason, that was the only problem in this case.

1 Like