CurrentUser object in Serverside Code

Hints, Tips and Tricks

Technical Hints Tips and Tricks that cover customization and development using Sage CRM. API usage and coding are covered.

CurrentUser object in Serverside Code

  • Comments 1
  • Likes
The CurrentUser object can be used in all serverside code including Create Scripts, Validation scripts, Table Level scripts and Workflow javascript conditions.

It provides information about the current user session.

You can list the properties of the CurrentUser object by using this snippet of code in any Create Script.

Valid = false;
ErrorStr ='';
var recCaption
var x
for (x in CurrentUser)
{
recCaption = eWare.FindRecord("custom_captions","capt_code = '"+x+"'");
ErrorStr += x +' ('+recCaption.capt_us+'): '+CurrentUser[x]+'
';
}

We can see the result:

user_displayname (User Template): Susan Maye
user_pwdprofile (Administration): 1
user_userid (User): 4
user_primarychannelid (Primary Team): 1
user_logon (User Name): MayeS
user_lastname (Last Name): Maye
user_firstname (First Name): Susan
user_language (Language): US
user_department (Department): US Sales
user_phone (Phone): 212 954 1902
user_fax (Fax): 212 954 1900
user_emailaddress (E-mail): mayes@panoplytech.com
user_per_admin (Administration): 1
user_resource (Resource): False
user_externallogonallowed (External Logon Allowed): True
user_primaryterritory (Home Territory): -2147483639
user_isterritorymanager (Territory Manager):
user_territoryprofile (Profile Name): 3
user_per_user (Info Admin User Rights): False
user_per_product (Info Admin Product Rights): True
user_per_currency (Info Admin Currency Rights): True
user_per_data (Info Admin Data Rights): False
user_offlineaccessallowed (PDA/WAP Access): True
user_rollupto (Forecasting - Reports To): 8
user_per_customise (Info Admin Customize): False
user_minmemory (Min memory for SQL to use on client (MB)):
user_maxmemory (Max memory for SQL to use on client (MB)):
user_title (Title): US and Canada Sales Manager
user_location (Location): NewYork
user_deskid (Desk Location): 5/2122
user_per_infoadmin (Info Admin Rights):
user_device_machinename (Device Name):
user_per_solutions (Solutions): 0
user_offlinesecurity (Allow Offline Access):
user_istemplate (Template): N
user_templatename (Template Name):
user_webserviceenabled (Allow Web Service Access): False
user_masterpersid (Hosting Master ID):
user_lastserver (undefined):
user_enabledonotreprice (Enable Overwrite price):
user_prf (undefined): mm/dd/yyyy
Comments
  • Hi Jeff,

    I have a problem inside javascript condition of the workflow.

    I am giving the following condition to validate the path of the workflow but the validation is not happening and neither is it giving me any error.

    Valid=(case_warrantyenddate <= '#T');[Also tried without single quotes i.e. #T]

    But when I click on Change Button for case and save it again without even changing a single field the action button is appearing and the validation is also happening.But again when I click on the case top content the case summary page refreshes and the action button disappears.

    Kindly help me on this.