Name

sn_install_base.CSMRelationshipService_ContactSoldProduct

Description

Implements extension point global.CSMRelationshipServiceEP Extension point for CSM Relationship framework.

Script

var CSMRelationshipService_ContactSoldProduct = Class.create();
CSMRelationshipService_ContactSoldProduct.prototype = Object.extendsObject(sn_install_base.CSMRelationshipService_SoldProductRelatedParty, {
  initialize: function() {
  	sn_install_base.CSMRelationshipService_SoldProductRelatedParty.prototype.initialize.call(this);
  	this.accountUtil = this._getAccountHelper(); //Invoking global Account through sandbox
  },
  
  canProcess: function(relationship, additionalParams) {
  	if(gs.nil(relationship))
  		return false;
  			
  	// Utah implementation - Sold Product Related Party table OR Contact Sold Product table
  	if (this._isContactSoldProduct(additionalParams))
  		return (relationship == global.CSMBaseConstants.SOLD_PRODUCT_RELATED_PARTY) || (relationship == global.CSMRelationshipConstants.RELATIONSHIP_CONTACT_SOLDPRODUCT);

  	// Tokyo implementation - Contact Sold Product table
  	return relationship == global.CSMRelationshipConstants.RELATIONSHIP_CONTACT_SOLDPRODUCT;
  },
  
  _addPersonaCriteria: function(relationshipGR) {
  	relationshipGR.addQuery(global.CSMRelationshipConstants.FIELD_CONTACT, gs.getUserID());
  },
  
  _addAdditionalAccountCriteria: function(relationshipGR) {
  	if (this.__getAdditionalParam(global.CSMRelationshipConstants.IS_ACCOUNT_QUERY)) {
  		relationshipGR.addNullQuery(global.CSMRelationshipConstants.FIELD_CONTACT);
  		relationshipGR.addNullQuery(global.CSMRelationshipConstants.FIELD_CONSUMER);
  		relationshipGR.addNotNullQuery(global.CSMRelationshipConstants.FIELD_ACCOUNT);
  		if (!this.__getAdditionalParam(global.CSMRelationshipConstants.NO_PERSONA_ACCOUNT_QUERY))
  			relationshipGR.addQuery(global.CSMRelationshipConstants.FIELD_ACCOUNT, this.accountUtil.getUserAccount());
  	}
  },
  
  _addAdditionalContactEntities: function(entities) {
  	if (this.context.entityName && this.context.entityName == global.CSMRelationshipConstants.FIELD_CONTACT && this.context.current && this._isChildOf(global.CSMBaseConstants.CASE_TABLE, this.context.current.getTableName())) {
  		// add current.sold_product.contact
  		if (!gs.nil(this.context.current[global.CSMRelationshipConstants.SOLD_PRODUCT])) {
  			var contactEntity = this.context.current[global.CSMRelationshipConstants.SOLD_PRODUCT][global.CSMRelationshipConstants.FIELD_CONTACT] + '';
  			if (!gs.nil(contactEntity))
  				entities[contactEntity] = true;
  		}
  	}
  },
  
  _isContactSoldProduct: function(additionalParams) {
  	return gs.nil(additionalParams) ? false : additionalParams[global.CSMRelationshipConstants.IS_CONTACT_SOLD_PRODUCT];
  },
  
  type: 'CSMRelationshipService_ContactSoldProduct'
});

Sys ID

2c0aba2177867010d3ef07dc7d5a99bc

Offical Documentation

Official Docs: