Wildcard for group membership? New to authoring so have mercy :)

(imported topic written by SystemAdmin)

Hi,

I’m trying to create a new Managed Property based on first part of users’ i.d.

First four letters/#s of a user id denotes what department is linked to that i.d.

So if a group i.d. starts with 1234 and remaining 4 spots (5678) are unique to the user, is there a way to filter so it only looks at the first 4 letters/numbers?

Will an * work as a wildcard so it singles out all user id’s that start with “1234” and places them in “Group A”?

example: will it place 1234joe and 1234zed in same group “Group A”?

Please see code snippet below:

if (value “DefaultUserName” of key “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon” of registry as string = “1234*”) then “Group A”

(imported comment written by NoahSalzman)

There are a few ways to pull parts of a string if you know the position (in the string) you are starting from.

concatenation of characters (0;1;2;3) of “1234abc”

will return the string “1234”

You can also use

preceding text of position 4 of “1234abc”

to get the same result. In your case this turns into something like:

if (preceding text of position 4 of (value “DefaultUserName” of key “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon” of registry as string) = “1234”) then “Group A”

Edit:

firsts 4 of

is even simpler

(imported comment written by SystemAdmin)

Thank you for the reply!

going by your edit “firsts 4 of” would the code look like this?:

if (firsts 4 of (value “DefaultUserName” of key “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon” of registry as string) = “1234”) then “Group A”

thanks!

(imported comment written by NoahSalzman)

Yes, that should to it.

I recommend you check out the

Fixlet Debugger

so you can test your Relevance scripts before deploying them. It’s very handy.

(imported comment written by SystemAdmin)

Thanks for the tip!

One more thing, going back to original code, could I have replaced the “=” with “starts with” and achieved the same results, or would it be open to possible issues?

example:

if (value “DefaultUserName” of key “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon” of registry as string starts with “1234”) then “Group A”

(imported comment written by NoahSalzman)

Yes, even better. I don’t believe there are any gotchas (given the parameters you described).