Name

sn_customerservice.CSMInteractionChannelUserProfileExtPointImpl

Description

Implements extension point global.InteractionChannelUserProfileExtPoint Used for adding BU-specific logic to populate the user_table & user_document of an interaction s channel_user_profile.

Script

var CSMInteractionChannelUserProfileExtPointImpl = Class.create();
CSMInteractionChannelUserProfileExtPointImpl.prototype = {
  initialize: function() {
  },
  
  doesInteractionChangeTriggerProfileUpdate: function(current, previous /*null when interaction is new*/) {
  	// Given the current and previous state of an interaction GlideRecord, determine whether
  	// the change warrants updating the user_document of the interaction's channel_user_profile.
      var contact = current.getValue('contact');
  	var consumer = current.getValue('consumer');
  	
  	if (gs.nil(contact)  && gs.nil(consumer))
  		return false;
  	
  	// Update profile if contact or consumer is new or changed
  	return (gs.nil(previous) || contact != previous.getValue('contact') || consumer != previous.getValue('consumer'));
  },

  getUserElementForInteraction: function(interactionGR) {
  	// For the given interaction, return the GlideElement for the reference field representing the person
  	// that should be saved in the user_document of the interaction's channel_user_profile.	
      if(!gs.nil(interactionGR.getValue('consumer')))
  		return interactionGR.getElement('consumer');
  	
      if(!gs.nil(interactionGR.getValue('contact')))
  		return interactionGR.getElement('contact');
  	
  	return null;
  },

  getInteractionUserElementForProfile: function(interactionGR, channelUserProfileGR) {
  	// For the given interaction and channel_user_profile, return the GlideElement for the 
  	// reference field in interaction that should used to store the value currently in
  	// channel_user_profile.user_document.
  	var userTable = channelUserProfileGR.getValue('user_table');
  	
  	if ('csm_consumer'==userTable)
  		return interactionGR.getElement('consumer');

  	if ('customer_contact'==userTable){
  		interactionGR.setValue("account", channelUserProfileGR.user_document.account);
  		return interactionGR.getElement('contact');
  	}
  	
      return null;
  },
  
  type: 'CSMInteractionChannelUserProfileExtPointImpl'
};

Sys ID

e9e6f43c7363401096e4680c5ef6a7c9

Offical Documentation

Official Docs: