get USER ID and Security Role from HcmWorker

Example Code :

display Notes TIDgetUserIdAndRoles()
{
    DirPerson               DirPerson;
    DirPersonUser           DirPersonUser;
    SecurityUserRole        SecurityUserRole;
    SecurityRole            SecurityRole;
    Notes                   returnNotes;
    str value;
    ;


    DirPerson       = DirPerson::find(this.Person);
    DirPersonUser   = DirPersonUser::findWorker(this.RecId);
    returnNotes      = strFmt("User ID : %1 \n\n ",DirPersonUser.User);
    returnNotes      = strFmt("%1Security Roles : \n",returnNotes);
    
    while select * from SecurityUserRole 
        where SecurityUserRole.User == DirPersonUser.User
    join SecurityRole
        where SecurityRole.RecId == SecurityUserRole.SecurityRole
    {
        if(subStr(SecurityRole.Name,1,1) == '@')
        {
            value = SysLabel::labelId2String2(SecurityRole.Name, companyinfo::languageId());
            returnNotes = strFmt("%1 %2\n",returnNotes,value);
        }
        else
        {
            returnNotes = strFmt("%1 %2\n",returnNotes, SecurityRole.Name);
        }
    }
    
    return returnNotes;
}

create Address , Phone , Email for Worker example code

Static void WorkerHireAddressUpdate(HCMworker _worker,StreetName _address = "",str _Phone = "",str _email = "")
{
    
    HcmWorker                   hcmWorker;
    DirPersonRecId              _dirPersonRecid;
    DirPartyPostalAddressView   addressView;
    dirPartyContactInfoView     contactView;
    DirParty                    dirParty;
    container                   roles;
    
    HcmWorker = _worker;
    _dirPersonRecid = HcmWorker.Person;
    roles  = [LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Home).RecId];
    
    //create address
    DirParty = DirParty::constructFromPartyRecId(_dirPersonRecid);
    if(_address)
    {
        //addressView.LocationName  
        //addressView.City    = 
        //addressView.State   = 
        //addressView.ZipCode =
        
        addressView.CountryRegionId = LogisticsAddressCountryRegion::findByISOCode(SysCountryRegionCode::countryInfo(curext())).CountryRegionId;
        addressView.Street  = _address;
        addressView.IsPrimary   = NoYes::Yes;
        addressView.Party   = _dirPersonRecid;
        DirParty.createOrUpdatePostalAddress(addressView,roles);
    }
    
    //create primary email
    if(_email)
    {
        contactView.clear();
        contactView.LocationName                = 'Primary Email';
        contactView.Locator                     = _email;
        contactView.Type                        = LogisticsElectronicAddressMethodType::Email;
        contactView.Party                       = _dirPersonRecid;
        contactView.IsPrimary                   = NoYes::Yes;
        dirParty.createOrUpdateContactInfo(contactView);
    }
    
    //create primary phone
    if(_Phone)
    {
        contactView.clear();
        contactView.LocationName                = 'Primary Phone';
        contactView.Locator                     = _Phone;
        contactView.Type                        = LogisticsElectronicAddressMethodType::Phone;
        contactView.Party                       = _dirPersonRecid;
        contactView.IsPrimary                   = NoYes::Yes;
        dirParty.createOrUpdateContactInfo(contactView);
    }

}