Help with the code fix

Can someone help with the below code fix. I was getting below error message. An unexpected error occurred: sailpoint.tools.GeneralException: BeanShell script error: bsh.ParseException: Parse error at line 7, column 25. Encountered: ; BSF info: script at line: 0 column: columnNo

import sailpoint.object.Configuration;

globvar = context.getObjectByName(Configuration.class, “Global Variables”);

String upnPostFix = globvar.getString(“gv_upn_postfix”);

if(null != identity && null != identity.getAttribute(“name”)) {
String name = identity.getAttribute(“name”);
String firstThree = name.length() >= 3 ? name.substring(0, 3) : name;
String userID = firstThree.concat(“ABCA”);

return userID + upnPostFix;

}

return null;

Thanks

Hi @GutteStolt ,
I think the parseException is because of the symbols && and >= . these should be converted into && and >= respectively.
thanks
Siddardha

@GutteStolt -

The error you’re encountering:

An unexpected error occurred: sailpoint.tools.GeneralException: BeanShell script error: bsh.ParseException: Parse error at line 7, column 25. Encountered: ; 

indicates a syntax issue in your BeanShell script, specifically at the point where you are concatenating or defining strings.

Likely Root Cause:

The error most likely stems from the usage of invalid double quotes (curly quotes “ ” instead of standard quotes " ") in the following lines:

globvar = context.getObjectByName(Configuration.class, “Global Variables”);
String upnPostFix = globvar.getString(“gv_upn_postfix”);
String userID = firstThree.concat(“ABCA”);

These curly quotes are not valid syntax in Java/BeanShell, and the parser fails with a ParseException.


Corrected Script:

Replace all curly quotes with proper ASCII double quotes:

import sailpoint.object.Configuration;

Configuration globvar = context.getObjectByName(Configuration.class, "Global Variables");

String upnPostFix = globvar.getString("gv_upn_postfix");

if (null != identity && null != identity.getAttribute("name")) {
    String name = identity.getAttribute("name");
    String firstThree = name.length() >= 3 ? name.substring(0, 3) : name;
    String userID = firstThree.concat("ABCA");

    return userID + upnPostFix;
}

return null;

Pro Tip:

When pasting code into IdentityIQ or any script field, always ensure quotes are plain, especially when copying from Word, Google Docs, or formatted web editors.

Hope this helps.