Service Board > Max for Developers > Max Groovy APIs > User Information and Parameters API
User Information and Parameters API
To retrieve information and parameters for the currently logged-in user or another specified user, you use the Groovy API com.servicemax.core.utils.UserInfo.
Methods
Retrieve the ID of the Logged-in User
public static UUID getUserId()
Retrieve the Record Associated With the Logged-in User
public static MaxObject getUser()
Retrieve a Specified User Parameter Associated With the Logged-in User
public static Object getUserParameter(String parameter)
Retrieve the Language Record Associated With the Logged-in User
public static MaxObject getUserLanguage()
Retrieve the Time Zone for the Logged-in User
public static DateTimeZone getUserTimeZone()
Retrieve the Date Format for the Logged-in User
public static String getUserDateFormat()
For HTTP Requests, Retrieve Attributes for the Logged-in User’s HTTP Session
public static Object getUserSessionAttribute(String attributeName)
Set a Specified User Parameter for the Logged-in User
public static void setUserParameter(String parameterName, Object parameterValue)
Set a Specified HTTP Session Attribute for the Logged-in User
public static void setUserSessionAttribute(String attributeName, Object value)
Retrieve User Parameters for a Specified User
public static Object getUserParameter(UUID userId, String parameter)
Set User Parameters for a Specified User
public static void setUserParameter(UUID userId, String parameterName, Object parameterValue)
Get External OAuth Token for Logged-in User Authenticated by External OAuth Provider
* 
Available in Max version 5.0.0.1058 and OAuth version 5.0.0.101 and later.
Returns a Map, with the keys access_token, token_provider, and instance_url. If no external OAuth token is found, returns an empty Map.
Output Example
access_token=00D28000000sUmI!ASAAQLbLEqJ8O1v,
token_provider=login.salesforce.com,
instance_url=https://ap2.salesforce.com
Class Definition
public static Map getExternalOAuthToken()
Usage
To work with the following methods, you must first import the class.
import com.servicemax.core.utils.UserInfo;
Retrieve Information for the Logged-in User
def loggedUser = UserInfo.getUser();
println loggedUser.io_username;
println loggedUser.io_first_name;
println loggedUser.io_last_name;
Retrieve Language Associated With the Logged-in User
def lang = UserInfo.getUserLanguage();
println lang.getLanguageCode()
println lang.getUUID()
println lang.getDateFormat()
println lang.getLocale()
Retrieve Time Zone Associated With the Logged-in User
def timeZone = UserInfo.getUserTimeZone();
println timeZone.getID();
Retrieve Date Format Associated With the Logged-in User
def dateFormat = UserInfo.getUserDateFormat();
println dateFormat;
Retrieve the io_show_quick_tours_at_login User Parameter for the Logged-in User
println UserInfo.getUserParameter("io_show_quick_tours_at_login");
For HTTP Requests, Retrieve HTTP Session Attributes for the Logged-in User
println UserInfo.getUserSessionAttribute("my_session_attribute");
Retrieve Specified User Parameter (io_show_quick_tours_at_login) for a Specified User
def user = com.servicemax.core.Database.querySingleResult("SELECT io_uuid FROM io_user where io_username = 'newuser'")
println UserInfo.getUserParameter(user.io_uuid, "io_show_quick_tours_at_login");
Set Designer Application for the Logged-in User
def application = com.servicemax.core.Database.querySingleResult("SELECT io_uuid FROM io_application where io_identifier = 'designer'")
UserInfo.setUserParameter("io_default_application", application.io_uuid);
Set Designer Application for a Specified User
def user = com.servicemax.core.Database.querySingleResult("SELECT io_uuid FROM io_user where io_username = 'newuser'")
UserInfo.setUserParameter(user.io_uuid, "io_default_application", application.io_uuid);
For more information:
Was this helpful?