This topic describes API calls that your client applications can invoke to obtain the system timestamp, user information, and change user passwords.
Note: For a list of general API calls, see Data Calls Reference. For a list of describe calls, see Describe Calls Reference.
The following table lists the API utility calls described in this topic:
Description Task / Call
Retrieves the current system timestamp from the Web service.
getServerTimestamp
Retrieves personal information for the user associated with the current session.
getUserInfo
Changes a user’s password to a system-generated value.
resetPassword
Sets the specified user’s password to the specified value.
setPassword
getServerTimestamp
Retrieves the current system timestamp (Greenwich Mean Time (GMT) or Coordinated Universal Time (UTC) time zone) from the Web service.
Syntax
GetServerTimestampResult timestamp = sfdc.getServerTimestamp();
Usage
Use getServerTimestamp to obtain the current system timestamp from the Web service. You might do this if, for example, you need to use the exact timestamp for timing or data synchronization purposes. When you create or update an object, the Web service uses the system timestamp to update the CreatedDate and LastModifiedDate fields, respectively, in the object.
The getServerTimestamp call always returns the timestamp in Greenwich Mean Time (GMT) or Coordinated Universal Time (UTC) time zone. However, your local system might automatically display the results in your local time based on your time zone settings.
Note: Development tools differ in the way that they handle time data. Some development tools report the local time, while others report only the Greenwich Mean Time (GMT) or Coordinated Universal Time (UTC) time zone. To determine how your development tool handles time values, refer to its documentation.
Sample Code—Java
public void getServerTimestampSample() {
// Invoke the getServerTimestamp call and save the results try {
Calendar serverTime = binding.getServerTimestamp().getTimestamp();
System.out.println("Server time is: " + serverTime.getTime().toString());
} catch (Exception ex) {
System.out.println("An unexpected error has occurred." + ex.getMessage());
} }
Sample Code—C#
private void getServerTimeStamp() {
//Invoke the getServerTimeStamp call and save the results GetServerTimestampResult ts = binding.getServerTimestamp();
// Write the server timestamp to the diagnostics window
System.Diagnostics.Trace.WriteLine(ts.timestamp.ToUniversalTime);
}
Arguments None.
Response
GetServerTimestampResult
Fault
UnexpectedErrorFault
See Also:
Utility Calls Reference
http://www.sforce.com/us/resources/soap/sforce60/sforce_API_messages_getServerTimestamp.html
GetServerTimestampResult
The getServerTimestamp call returns a GetServerTimestampResult object, which has the following properties:
Description Type
Name
System timestamp of the Web service when the getServerTimestamp call was executed.
dateTime timestamp
getUserInfo
Retrieves personal information for the user associated with the current session.
Syntax
getUserInfo
Usage
Use getUserInfo to obtain personal information about the currently logged-in user. This convenience API call retrieves and aggregates common profile information that your client application can use for display purposes, performing currency calculations, and so on.
The getUserInfo call applies only to the username under which your client application has logged in. To retrieve additional personal information not found in the GetUserInfoResult object, you can call retrieve on the User object and pass in the userID returned by this call. To retrieve personal information about other users, you could call retrieve (if you know their user ID) or query on the User object.
Sample Code—Java
public void getUserInfoSample() {
GetUserInfoResult getUserInfoResult = null;
try {
// Invoke the getUserInfo call
getUserInfoResult = binding.getUserInfo();
// Display the returned user information
System.out.println("User's currency symbol: " + getUserInfoResult.getCurrencySymbol());
System.out.println("User's organization name: " + getUserInfoResult.getOrganizationName());
System.out.println("User's default currency code: " +
getUserInfoResult.getUserDefaultCurrencyIsoCode());
System.out.println("User's email: " + getUserInfoResult.getUserEmail());
System.out.println("User's full name: " + getUserInfoResult.getUserFullName());
System.out.println("User's user id: " + getUserInfoResult.getUserId());
System.out.println("User's language: " + getUserInfoResult.getUserLanguage());
System.out.println("User's locale: " + getUserInfoResult.getUserLocale());
System.out.println("User's timezone: " + getUserInfoResult.getUserTimeZone());
System.out.println("User's org is multi currency: " + getUserInfoResult.isOrganizationMultiCurrency());
} catch (Exception ex) {
System.out.println("An unexpected error has occurred." + ex.getMessage());
} }
Sample Code—C#
private void getUserInfo() {
//Invoke getUserInfo call and save the results in getUserInfoResult GetUserInfoResult ui = binding.getUserInfo();
// Get some of the user information String orgName = ui.organizationName;
String userFullName = ui.userFullName;
}
Arguments None.
Response
GetUserInfoResult
getUserInfo
Fault
The getUserInfo call returns a GetUserInfoResult object, which has the following properties:
Description Type
Name
Available in API version 7.0 and later. Indicates whether user interface modifications for the visually impaired are on (true) or off (false). The modifications facilitate the use of screen readers such as JAWS.
boolean accessibilityMode
Currency symbol to use for displaying currency values. Applicable only when organizationMultiCurrency is false.
string currencySymbol
Type of license assigned to the Profile associated with the user.
string licenseType
Profile ID of the profile associated with the role currently assigned to the user.
ID profileID
Organization ID. Allows third-party tools to uniquely identify individual organizations in Salesforce, which is useful for retrieving billing or organization-wide setup information.
ID organizationId
Indicates whether the user’s organization uses multiple currencies (true) or not (false).
boolean organizationMultiCurrency
Name of the user’s organization or company.
string organizationName
Role ID of the role currently assigned to the user.
ID roleID
Default currency ISO code. Applicable only when
organizationMultiCurrency is true. When the logged-in user creates string
userDefaultCurrencyIsoCode
any objects that have a currency ISO code, the Web service uses this currency ISO code if it is not explicitly specified in the create call.
User’s email address.
User’s language, which controls the language for labels displayed in an application. String is 2-5 characters long. The first two characters are string
userLanguage
always an ISO language code, for example “fr” or “en.” If the value is further qualified by country, then the string also has an underscore (_) and another ISO country code, for example “US” or “UK. For example, the string for the United States is “en_US”, and the string for French Canadian is
“fr_CA.”
For a list of the languages that Salesforce supports, see the Salesforce online help topic "What languages does Salesforce support?"
getUserInfo
Description Type
Name
User’s locale, which controls the formatting of dates and choice of symbols for currency. The first two characters are always an ISO language code, string
userLocale
for example “fr” or “en.” If the value is further qualified by country, then the string also has an underscore (_) and another ISO country code, for example “US” or “UK. For example, the string for the United States is
“en_US”, and the string for French Canadian is “fr_CA.”
User’s login name.
string userName
User’s time zone.
string userTimeZone
Available in API version 7.0 and later. Returns the value Theme2 if the user is using the newer user interface theme of the online application, string
userUiSkin
labeled “Salesforce.” Returns Theme1 if the user is using the older user interface theme, labeled “Salesforce Classic.” In the online application, this look and feel setting is configurable at Setup ➤ Customize ➤ User Interface. See User Interface Themes.
resetPassword
Changes a user’s password to a temporary, system-generated value.
Syntax
string password = sfdc.resetPassword(ID userID);
Usage
Use resetPassword to request that the Apex Web service change the password of a User or SelfServiceUser, and return a system-generated password string of random letters and numbers. Use setPassword instead if you want to set the password to a specific value.
Your client application must be logged in with sufficient access rights to change the password for the specified user. For more information, see Factors that Affect Data Access.
For information on IDs, see ID Field Type.
Sample Code—Java
public void resetPasswordSample() {
// Specify the user ID of the password to reset String idToReset = "005x0000000fFLnAAM";
// Invoke the resetPasswordResult call try {
ResetPasswordResult resetPasswordResult = binding.resetPassword(idToReset);
// Display the new server-generated password
System.out.println(resetPasswordResult.getPassword());
} catch (Exception ex) {
System.out.println("An unexpected error has occurred." + ex.getMessage());
} }
resetPassword