The CSUserProfile class handles the querying and storage of a website user's profile details.
The CSUserProfile class includes methods for the retrieval, update, and removal of a particular user's profile. It also provides a method that checks for the existence of a user's profile. All such methods require that certain database and key information (UserID, for example) be specified via the set methods provided, prior to their invocation.
A website user includes a user's account, their login details, and their profile. Profiles are defined and managed using iCM forms. See User Profiles for more information about the standard forms.
Methods
Parameters must use the get-set structure described in the introduction - Java API (CSObjects).
get a string (comma separated) that lists the properties whose values should be returned, an asterisk to indicate that all properties should be returned, or an empty string to return nothingset the properties which should be set before the specified method is performed
CSUserProfile_delete
Deletes a user's profile. Note that the whole profile object associated with the user is deleted, this method doesn't simply delete the values in the profile.
Request Parameters
One of
Name | Type | Description |
---|---|---|
get | String | A comma separated list of properties to return |
set.ObjectID | Integer | Optional, the ID of the underlying user profile object |
set.UserID | Integer | Optional, the ID of the user |
set.UserName | String | Optional, the username that identifies the user account, which will likely be a GUID, not the login username |
{
"get": "",
"set": {
"UserName": "TIMG",
"UserID": 186,
"ObjectID": 19307
}
}
Response
The
{
"id": 416,
"result": {
"data": {
"itemData": {}
},
"success": true
},
"jsonrpc": "2.0"
}
Example
Request:
function(params, credentials) {
var profile = this.callWorkerMethod("icmapi", "CSUserProfile_delete", {
"get": "",
"set": {
"UserName": "B947AC66-3BB7-4F90-B0E0-DCE07AFBD537"
}
});
return profile;
}
Response:
{
"id": 416,
"result": {
"data": {
"itemData": {}
},
"success": true
},
"jsonrpc": "2.0"
}
CSUserProfile_exist
Checks to see whether a profile exists.
Request Parameters
One of
Name | Type | Description |
---|---|---|
get | String | Set as an empty string |
set.ObjectID | Integer | Optional, the ID of the underlying user profile object |
set.UserID | Integer | Optional, the ID of the user |
set.UserName | String | Optional, the username that identifies the user account, which will likely be a GUID, not the login username |
{
"get": "",
"set": {
"UserName": "TIMG",
"UserID": 186,
"ObjectID": 19307
}
}
Response
The
{
"id": 416,
"result": {
"data": {
"returnValue": true,
"itemData": {}
},
"success": true
},
"jsonrpc": "2.0"
}
Example
Note the use of
Request:
function(params, credentials) {
var profile = this.callWorkerMethod("icmapi", "CSUserProfile_exist", {
"get": "",
"set": {
"UserName": "B947AC66-3BB7-4F90-B0E0-DCE07AFBD537"
}
}, {
"rawMode": true
});
return profile;
}
Response:
{
"id": 416,
"result": {
"data": {
"returnValue": true,
"itemData": {}
},
"success": true
},
"jsonrpc": "2.0"
}
CSUserProfile_get
Retrieves a user's profile from the database.
Request Parameters
All properties in the
Name | Type | Description |
---|---|---|
get | String | A comma separated list of properties to return |
set.DetailLevel | Integer | Optional, the detail level to return, default 4 |
set.ObjectID | Integer | Optional, the ID of the underlying user profile object |
set.UserID | Integer | Optional, the ID of the user |
set.UserName | String | Optional, the username that identifies the user account, which will likely be a GUID, not the login username |
{
"get": "",
"set": {
"UserName": "TIMG",
"UserID": 186,
"ObjectID": 19307,
"DetailLevel": 4
}
}
Response
The
{
"id": 51,
"result": {
"data": {
"itemData": {}
},
"success": true
},
"jsonrpc": "2.0"
}
Example
Request:
function(params, credentials) {
var profile = this.callWorkerMethod("icmapi", "CSUserProfile_get", {
"get": "ObjectData,UserID",
"set": {
"UserName": "TIMG",
"DetailLevel": 4
}
});
return profile;
}
Response:
Note that using
{
"id": 291,
"result": {
"_ItemClass": "CSUserProfile",
"UserID": 186,
"ObjectData": {
"PREFNAME": "Tim",
"MOBILE": "",
"LASTNAME": "Gulliver-Haynes",
"EMAIL": "support@gossinteractive.com",
"FIRSTNAME": "Tim",
"TELEPHONE": ""
}
},
"jsonrpc": "2.0"
}
CSUserProfile_update
Updates a user's profile.
Request Parameters
One of
Name | Type | Description |
---|---|---|
get | String | A comma separated list of properties to return. Update returns the display name template for the user in the |
set.ObjectData | Object | The user profile object. The properties set will overwrite existing values, those not provided will remain unchanged |
set.ObjectID | Integer | Optional, the ID of the underlying user profile object |
set.UserID | Integer | Optional, the ID of the user |
set.UserName | String | Optional, the username that identifies the user account, which will likely be a GUID, not the login username |
{
"get": "",
"set": {
"UserName": "TIMG",
"UserID": 186,
"ObjectID": 19307,
"ObjectData": {}
}
}
Response
The
{
"id": 121,
"result": {
"data": {
"itemData": {}
},
"success": true
},
"jsonrpc": "2.0"
}
Example
This example updates a single field in the profile and returns the display name as well as the full profile.
Request:
function(params, credentials) {
var profile = this.callWorkerMethod("icmapi", "CSUserProfile_update", {
"get": "HandlebarsResult,ObjectData",
"set": {
"UserName": "B947AC66-3BB7-4F90-B0E0-DCE07AFBD537",
"ObjectData": {
"PREFNAME": "new prefname"
}
}
});
return profile;
}
Response:
Note that using
{
"id": 123,
"result": {
"_ItemClass": "CSUserProfile",
"HandlebarsResult": "User, Dummy, support@gossinteractive.com,",
"ObjectData": {
"PREFNAME": "new prefname",
"MOBILE": "",
"LASTNAME": "User",
"EMAIL": "support@gossinteractive.com",
"FIRSTNAME": "Dummy",
"TELEPHONE": ""
}
},
"jsonrpc": "2.0"
}
Properties
Name | Type | Description |
---|---|---|
CreatedBy | String | The username of the user who created this userprofile. - If the profile was created as part of our website registration process, this will match the UserName - If the profile was created during an Assisted Service registration process, or directly in iCM, this will be the username of the user who created the profile - If the profile was created by a third party login (login with Google, Facebook etc), this will include the name of that provider, eg "AUTHWORKER_FACEBOOK" |
DateCreated | DateTime | The date and time on which this profile was created, for example "2020-03-26T11:54:17Z" |
DateLastUpdated | DateTime | The date and time on which this profile was last updated, for example "2022-10-06T15:14:27Z" |
DetailLevel | Integer | The level of detail returned. One of: 1 - LEVEL_ID: The UserID, UserName and UserProfileType, 2 - LEVEL_SUMMARY: Plus the underlying ObjectID, Label and Type 3 - LEVEL_DETAIL: Plus the DateCreated, DateLastUpdated, CreatedBy and LastUpdatedBy 4 - LEVEL_ALL: Plus the full profile |
HandlebarsResult | String | Only returned by the update method. The result of the display name template found in iCM's User Settings |
Label | String | The label of the underlying object. This matches the UserID |
LastUpdatedBy | String | The username of the user who last updated this profile |
ObjectData | Object | The user profile |
ObjectID | Integer | The ID of the underlying user profile object |
Type | String | The type of the underlying user profile object. This will match the UserProfileType |
UserID | Integer | The ID of the user |
UserName | String | The username. This is the username that identifies the account, which will likely be a GUID, not the login username |
UserProfileType | String | The user profile type, usually defined by a form, eg "FORM_USERPROFILE" |
{
"_ItemClass": "CSUserProfile",
"CreatedBy": "B947AC66-3BB7-4F90-B0E0-DCE07AFBD537",
"DateCreated": "2022-10-26T09:36:17Z",
"DateLastUpdated": "2022-10-27T11:03:11Z",
"DetailLevel": 4,
"HandlebarsResult": "Gulliver-Haynes, Tim",
"Label": "217",
"LastUpdatedBy": "UNKNOWN",
"ObjectData": {
"PREFNAME": "My Prefname",
"MOBILE": "",
"LASTNAME": "Gulliver-Haynes",
"EMAIL": "",
"FIRSTNAME": "Tim",
"TELEPHONE": ""
},
"ObjectID": 20064,
"Type": "FORM_USERPROFILE",
"UserID": 217,
"UserName": "B947AC66-3BB7-4F90-B0E0-DCE07AFBD537",
"UserProfileType": "FORM_USERPROFILE"
}