Toggle menu

CSUserProfile

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 nothing
  • set 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 ObjectID, UserID or UserName must be set.

NameTypeDescription
getStringA comma separated list of properties to return
set.ObjectIDIntegerOptional, the ID of the underlying user profile object
set.UserIDIntegerOptional, the ID of the user
set.UserNameStringOptional, 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 itemData object includes the properties listed in the get parameter.

{
    "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 ObjectID, UserID or UserName must be set. get should be set as an empty string.

NameTypeDescription
getStringSet as an empty string
set.ObjectIDIntegerOptional, the ID of the underlying user profile object
set.UserIDIntegerOptional, the ID of the user
set.UserNameStringOptional, 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 returnValue will be true if the user profile exists.

{
    "id": 416,
    "result": {
        "data": {
            "returnValue": true,
            "itemData": {}
        },
        "success": true
    },
    "jsonrpc": "2.0"
}

Example

Note the use of rawMode: true when working with this.callWorkerMethod so that the full response can be seen, not just the itemData object.

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 set object are optional. Set one of ObjectID , UserID or UserName to return details about that user. Set an empty object to return an empty profile object.

NameTypeDescription
getStringA comma separated list of properties to return
set.DetailLevelIntegerOptional, the detail level to return, default 4
set.ObjectIDIntegerOptional, the ID of the underlying user profile object
set.UserIDIntegerOptional, the ID of the user
set.UserNameStringOptional, 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 itemData object includes the properties listed in the get parameter.

{
    "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 this.callWorkerMethod in an End Point parses the response, only returning the itemData in the result.

{
    "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 ObjectID, UserID or UserName must be set.

NameTypeDescription
getStringA comma separated list of properties to return. Update returns the display name template for the user in the HandlebarsResult property
set.ObjectDataObjectThe user profile object. The properties set will overwrite existing values, those not provided will remain unchanged
set.ObjectIDIntegerOptional, the ID of the underlying user profile object
set.UserIDIntegerOptional, the ID of the user
set.UserNameStringOptional, 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 itemData object includes the properties listed in the get parameter.

{
    "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 this.callWorkerMethod in an End Point parses the response, only returning the itemData in the result.

{
    "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

NameTypeDescription
CreatedByStringThe 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"
DateCreatedDateTimeThe date and time on which this profile was created, for example "2020-03-26T11:54:17Z"
DateLastUpdatedDateTimeThe date and time on which this profile was last updated, for example "2022-10-06T15:14:27Z"
DetailLevelIntegerThe 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
HandlebarsResultStringOnly returned by the update method. The result of the display name template found in iCM's User Settings
LabelStringThe label of the underlying object. This matches the UserID
LastUpdatedByStringThe username of the user who last updated this profile
ObjectDataObjectThe user profile
ObjectIDIntegerThe ID of the underlying user profile object
TypeStringThe type of the underlying user profile object. This will match the UserProfileType
UserIDIntegerThe ID of the user
UserNameStringThe username. This is the username that identifies the account, which will likely be a GUID, not the login username
UserProfileTypeStringThe 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"
}

Last modified on 27 October 2022

Share this page

Facebook icon Twitter icon email icon

Print

print icon