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);
    }

}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s