Name
sn_customerservice.CSMRelatedPartyUtilSNC
Description
No description available
Script
var CSMRelatedPartyUtilSNC = Class.create();
CSMRelatedPartyUtilSNC.prototype = {
initialize: function() {
},
/*
* Function which restricts the Tables which will be shown in the configuration
*/
process: function() {
var result = [];
result.push("customer_account");
result.push("csm_consumer");
result.push("customer_contact");
result.push("sys_user");
if(this.isServiceOrganizationPluginActive())
result.push(global.CSMBaseConstants.SERVICE_ORGANIZATION_TABLE);
return result;
},
/*
* Function which gets the List of all the Party Types associated with the particular Case Record
*/
getPartyType: function(current){
var result = "applies_to=" + current.case_record.sys_class_name;
var restrictedEntity = [];
var partyGr = new GlideRecord(global.CSMBaseConstants.RELATED_PARTY_CONFIG_TABLE);
partyGr.addEncodedQuery(result);
partyGr.query();
while(partyGr.next()){
if(!gs.nil(partyGr.getValue('entity_type'))){
var entityGr= new GlideRecord(partyGr.getValue('entity_type'));
if(!entityGr.canRead()){
restrictedEntity.push(partyGr.getValue('entity_type'));
}
}
}
for (var item in restrictedEntity){
result+="^entity_type!=" + restrictedEntity[item];
}
result+="^ORentity_type=NULL";
return result;
},
/*
* Function which queries all the Party types associated with the Record.
*/
getAllPartyTypeData: function(current, tableName){
var partyTypeConfig = {};
var partyGr = new GlideRecord(global.CSMBaseConstants.RELATED_PARTY_CONFIG_TABLE);
partyGr.addEncodedQuery("applies_to=" + (tableName || current.case_record.sys_class_name));
partyGr.query();
while(partyGr.next()){
partyTypeConfig[partyGr.sys_id] = partyGr.getValue("entity_type");
}
return partyTypeConfig;
},
/*
* Function which sets the reference qualifier on the Related Party reference field based on the Related Party Configuration table.
*/
getReferenceQualifier: function(partyConfig){
var entityType = partyConfig.reference_condition+'';
if(!gs.nil(current) && !gs.nil(current.case_record) && partyConfig.entity_type == 'customer_contact'){
if(current.case_record.sys_class_name == global.CSMBaseConstants.CASE_TABLE && !gs.nil(current.case_record.account)){
entityType = entityType + "^" + new global.CSManagementUtils().getPartnerAndCustomerContacts(current.case_record.account);
}
}
return entityType;
},
/*
* Function to get the Calculated name based on the individual Reference Fiedls
*/
getCalculatedName: function(current){
var calculatedName = "";
if(current.account)
calculatedName = current.account.name;
if(current.consumer)
calculatedName = current.consumer.name;
if(current.user)
calculatedName = current.user.name;
return calculatedName;
},
getResponsibilityRefQual: function(current){
var refqual = "";
if(current && current.entity_type)
refqual="type=NULL^ORtype="+current.entity_type;
return refqual;
},
/*
* returns true if service organization plugin is active.
*/
isServiceOrganizationPluginActive: function() {
return GlidePluginManager.isActive(global.CSMBaseConstants.SERVICE_ORGANIZATION_PLUGIN);
},
type: 'CSMRelatedPartyUtilSNC'
};
Sys ID
ac27370521f55110f8771d5e8c02690d