Sync HR profile to User rofile

accsukant
Tera Contributor

Hi All ,

 

We have build some custom field in Hr profile and User profile. We have requirment when in case  HR pofile get some field  update same field  need to sync with User table .I have checked there is OOB BR (Synchronize fields to sys_user) and SI (hr_Synchronize and hr_Utils ) is there  but there nothing to mapping. so cusome filed update in HR profile same field can update in User table.

Can any one suggested how to do to  sync with HR profile and user table ?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

The BR invokes script include hr_Synchronize and function syncRecord

In that syncRecord function update the new field with your destination field and run once

The part in bold is newly added; Ensure you give correct field names from both the tables

var profileMap = {
                'address': { 'destField': 'street' },
                'country': { 'destField': 'country', 'func': this._mapProfileField },
                'position': { 'destField': 'title', 'func': this._mapProfileField },
                'source': { 'destField': 'hr_integration_source' },
                'u_custom_profile_field': { 'destField': 'u_user_field' }
            };

find_real_file.png

Similarly if you want sync to happen from User -> HR Profile

then update the else section like this

var userMap = {
                'country': { 'destField': 'country', 'func': this._mapUserField },
                'hr_integration_source': { 'destField': 'source' },
                'street': { 'destField': 'address' },
                'title': { 'destField': 'position', 'func': this._mapUserField },
                'u_user_field': { 'destField': 'u_custom_profile_field' }
            };

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

8 REPLIES 8

Jaspal Singh
Mega Patron
Mega Patron

If it is a custom field updated directly on HR Profile table why not create a new business rule instead of altering OOB

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

The BR invokes script include hr_Synchronize and function syncRecord

In that syncRecord function update the new field with your destination field and run once

The part in bold is newly added; Ensure you give correct field names from both the tables

var profileMap = {
                'address': { 'destField': 'street' },
                'country': { 'destField': 'country', 'func': this._mapProfileField },
                'position': { 'destField': 'title', 'func': this._mapProfileField },
                'source': { 'destField': 'hr_integration_source' },
                'u_custom_profile_field': { 'destField': 'u_user_field' }
            };

find_real_file.png

Similarly if you want sync to happen from User -> HR Profile

then update the else section like this

var userMap = {
                'country': { 'destField': 'country', 'func': this._mapUserField },
                'hr_integration_source': { 'destField': 'source' },
                'street': { 'destField': 'address' },
                'title': { 'destField': 'position', 'func': this._mapUserField },
                'u_user_field': { 'destField': 'u_custom_profile_field' }
            };

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@accsukant 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Just to check would it be recommended to update OOB script include