Name

sn_hr_core.ChannelUserProfileExtPointHR

Description

Implements extension point global.ChannelUserProfileExtPoint Used for adding BU-specific logic to populate the user_table & user_document of a channel_user_profile by finding a record with a field matching the profile s channel_user_id.

Script

var ChannelUserProfileExtPointHR = Class.create();
ChannelUserProfileExtPointHR.prototype = {
  initialize: function() {},

  /**
   * Search for a record in HR profile to set the HR profile sys_user as the user_document field of the a channel_user_profile,
   * using its channel and channel_user_id.
   *
   * If a record is found, return a result in this format:
   *     {"user_table" : <table name>, "user_document" : <sys_id>}
   *
   * Return null if a record is not found, or multiple results make it unclear which to choose
   */
  findUserDocumentForChannelUserID: function(channelUserProfileGR) {
      var channelUserID = channelUserProfileGR.getValue('channel_user_id');
      var channelId = channelUserProfileGR.getValue('channel');
      if (this._isValid(channelId)) {
          var grProfile = new GlideRecord('sn_hr_core_profile');
          grProfile.addQuery('work_mobile', channelUserID).addOrCondition('mobile_phone', channelUserID);
          grProfile.addQuery('user.active', true);
          grProfile.query();
          if (grProfile.getRowCount() == 1 && grProfile.next())
              return {
                  "user_table": 'sys_user',
                  "user_document": grProfile.getValue('user')
              };
      }
      return null;
  },
  /**
   * Description: Verifies if the channel is SMS messaging channel
   * @param {SysID} sysId of messaging channel
   * @return {boolean} true/false
   */
  _isValid: function(channelSysId) {
      return channelSysId == '5ae1b3e3771700105d7b3882a91061bd';
  },

  type: 'ChannelUserProfileExtPointHR'
};

Sys ID

5cb8858153d610100ad0ddeeff7b12a7

Offical Documentation

Official Docs: