Assistance with a custom expression (Domain\FirstName.LastName) Skip to main content
https://support.okta.com/help/answers?id=906f0000000qthlia0&refurl=http%3a%2f%2fsupport.okta.com%2fhelp%2fanswers
How satisfied are you with the Okta Help Center?
Thank you for your feedback!
How satisfied are you with the Okta Help Center?
1
2
3
4
5
Very Dissatisfied
Very satisfied
Enter content less than 200 characters.
Ask Search:
Miran GostoMiran Gosto 

Assistance with a custom expression (Domain\FirstName.LastName)

Hello,

I'm new to custom expressions and I'm trying to create a custom expression for (DOMAIN\John.Smith). I looked at the following articles but couldn't get the expression to work. 

http://developer.okta.com/docs/api/getting_started/okta_expression_lang.html

https://support.okta.com/help/blogdetail?id=a67F0000000blN1IAI

FirstName: John
LastName: Smith
Domain: DOMAIN

Expected result: DOMAIN\John.Smith 

I've tried variations of: 
DOMAIN\${user.firstName}.${user.lastName}

Output:
DOMAIN​${user.firstName}.Smith

I can't seem to get the backslash to work. I think I should be using a string expression but I can't get those to work either. Any assistance would be greatly appreciated.

Thank you! 

Miran
Best Answer chosen by Miran Gosto
Okta AdminOkta Admin
Give this a shot.  i tested in my preview org and seems to get the correct results you may be looking for.  You should be able to copy and paste.  the DOMAIN is static so just replace that with whatever your domain name is.

DOMAIN${"\\"}${f:toLowerCase(user.firstName)}.${f:toLowerCase(user.lastName)}

All Answers

Wils DawsonWils Dawson (Okta, Inc.)
Hi Miran,

It looks like that slash after DOMAIN (\) is trying to escape that dollar sign ($). In other words, the combination of the slash and dollar sign (\$) means a literal $ rather than a reference to the user variable. Try adding an extra slash so that instead of escaping the dollar sign, you'll escape the slash. So your expression should be something like:
 
DOMAIN\\${user.firstName}.${user.lastName}

Let me know if that doesn't work,
Wils
Miran GostoMiran Gosto
Hi Wils,

Thanks for the quick response. I actually tried that and got the following result.

DOMAIN\${user.firstName}.Smith

I also tried the following string. 
String.append("DOMAIN\",${user.firstName}.${user.lastName})
Result: 
String.append("DOMAIN\",John.Smith)

Please let me know if you have any other recommendations. 
Wils DawsonWils Dawson (Okta, Inc.)
Miran,

I have limited experience as well, so this is a hunch:

From the support blog post (https://support.okta.com/help/blogdetail?id=a67F0000000blN1IAI) that you posted eariler, it looks like this ${ } provides the "expression container". Perhaps you can only have one of those per field? So maybe try:
DOMAIN\user.$firstName.user.$lastName
If you don't see the slash after "DOMAIN" add an extra slash to escape it. Similarly, if you don't see the dot (.) after the first name, try adding a slash.

Let me know what you find,
Wils

UPDATE: forgot a dot
Eric KarlinskyEric Karlinsky (Okta, Inc.)
Hey Miran,

You might also try the String.join function:

String.join("","DOMAIN\",source.firstName,".",source.lastName)
Okta AdminOkta Admin
Give this a shot.  i tested in my preview org and seems to get the correct results you may be looking for.  You should be able to copy and paste.  the DOMAIN is static so just replace that with whatever your domain name is.

DOMAIN${"\\"}${f:toLowerCase(user.firstName)}.${f:toLowerCase(user.lastName)}
This was selected as the best answer
Miran GostoMiran Gosto
Thank you Jeff!! That worked!