
sp55m (sp55m) asked a question.
I have an incoming attribute with variable lengths and no common key (such as a @) and I only need the last four digits from the field. Any whizzes out there know the OEL command to count from the right instead of left?

Expression:
String.substring(appuser.stringAttribute, String.len(appuser.stringAttribute)-4, String.len(appuser.stringAttribute))
Summary
You'll need to change "appuser.stringAttribute" to be the actual attribute you have in your environment in all three places. Basically were using the String.substring function to trim the string to a shorter length. This function needs three inputs: the attribute, a starting character in the string, and an ending character in the string. The function will keep only the characters from where you specify to start and finish. The problem you explained is that we don't know the exact character count in the string. So what we do is use the String.len function to determine how many characters are in the string. Because you want the last four characters, we can use this as the ending character to give to the String.substring function. Now, we just need the starting character. Since you just want the last four, we use the String.len function again and just subtract four from it. This gives us the starting character in the string.
Expression Breakdown
Attribute value will equal "HelloWorld".
Examples Input/Ouput:
Input: IAmAString
Output: ring
Input: 477807248411
Output: 8411
Documentation:
https://developer.okta.com/docs/reference/okta-expression-language/#string-functions
Note: