Good evening. I have an urgent P2 incident.
The requirement is, when Catalog form is submitted, based on company code, it should set different Assignment groups.
For now, the below is working perfectly fine.
AU, IN, HK, SG tickets should assign to APAC SSC SAP MDM ENG
CN, KR, TW, MY, JP tickets should assign to APAC SSC SAP MDM
But for other company codes, example., when INF1 or AE24 is selected or other, it is coming to above APAC SSC SAP MDM ENG. I have found the issue in Workflow script that these are commented out.
For example, INF1 or AE24 needs to go to EMEA SSC SAP MDM group and not to APAC SSC SAP MDM ENG.
The script is attached below. Please help me out with this.
All the remaining company codes need to uncommented and should get assigned properly properly to the remaining groups. Please help me out. This is urgent.
setGroup();
function setGroup() {
var sysID = '';
// var sapCodeENG = ["INF2", "DM05", "TC03", "AU25", "HK05", "HK09", "TC07", "IN15", "IN24", "SG01", "IN16", "SG05", "SG06", "SG14", "Z016"];
var sapCodeENG = ["AU25", "HK05", "HK09", "IN15", "IN24", "SG01", "IN16", "SG05", "SG06", "SG14"];
// var sapCode = ["JP04", "JP05", "JP06", "KR02", "KR03", "MY01", "MY02", "IN19", "CN04", "CN10", "CN19", "TW02", "TW03"];
var sapCode = ["JP04", "JP05", "JP06", "KR02", "KR03", "MY01", "MY02", "CN04", "CN10", "CN19", "TW02", "TW03"];
//EMEA Region conditions
workflow.info('submitted request type Line No. 14: ' + current.variables.request_type);
if (current.variables.request_type == 'New' && current.variables.company_code.u_ssc == 'ZGBR') {
sysID = '3e7fde881bd6bc9004bb1fc3b24bcbc0'; // EMEA SSC SAP MDM Group
}
if (current.variables.request_type == 'Extend' && current.variables.what_company_code_are_you_extending.u_ssc == 'ZGBR') {
sysID = '3e7fde881bd6bc9004bb1fc3b24bcbc0'; // EMEA SSC SAP MDM Group
}
// New and Extend US Region conditions
if (current.variables.request_type == 'New' && (current.variables.company_code.u_ssc == 'ZUSA' || current.variables.company_code.u_ssc == 'ZUSI')) {
sysID = '027f9e881bd6bc9004bb1fc3b24bcb71'; // US SSC SAP MDM Group
}
if ((current.variables.request_type == 'Extend' && current.variables.what_company_code_are_you_extending.u_ssc == 'ZUSA') || (current.variables.request_type == 'Extend' && (current.variables.what_company_code_are_you_extending.u_ssc == 'ZUSI'))) {
sysID = '027f9e881bd6bc9004bb1fc3b24bcb71'; // US SSC SAP MDM Group
}
if (current.variables.account_group == 'ZAUS') {
sysID = 'fd7f5e881bd6bc9004bb1fc3b24bcbdf'; // US T&F SAP MDM Group
}
//APAC Region
// New Amend GRQ0324499
// Set Assignment group "APAC SSC SAP MDM ENG"
var sapIndex = 0;
var sapLength = sapCodeENG.length;
// for (sapIndex = 0; sapIndex < sapLength; sapIndex++) {
// if (current.variables.company_code.u_company_code == sapCodeENG[sapIndex]) {
// sysID = '7f629a941b459d906b7ab165464bcbb5'; // APAC SSC SAP MDM ENG
// }
// }
workflow.info("Line 52 Country code");
for (sapIndex = 0; sapIndex < sapCodeENG.length; sapIndex++) {
if (current.variables.company_code.u_company_code == sapCodeENG[sapIndex]) {
workflow.info("Line 55 Country code" + sapCodeENG[sapIndex]);
sysID = '7f629a941b459d906b7ab165464bcbb5'; // APAC SSC SAP MDM ENG
}
}
//Set Assignment group "APAC SSC SAP MDM"
var sapCodeIndex = 0;
var sapCodeLength = sapCode.length;
// for (sapCodeIndex = 0; sapCodeIndex < sapCodeLength; sapCodeIndex++) {
// if (current.variables.company_code.u_company_code == sapCode[sapCodeIndex]) {
// sysID = '667fde881bd6bc9004bb1fc3b24bcb7a'; // APAC SSC SAP MDM Group
// }
// }
workflow.info("Line 69 Country code");
for (sapCodeIndex = 0; sapCodeIndex < sapCode.length; sapCodeIndex++) {
if (current.variables.company_code.u_company_code == sapCode[sapCodeIndex]) {
workflow.info("Line 73 Country code" + sapCode[sapCodeIndex]);
sysID = '667fde881bd6bc9004bb1fc3b24bcb7a'; // APAC SSC SAP MDM Group
}
}
// if (current.variables.request_type == 'New' && current.variables.company_code.u_ssc == 'ZSGP') {
// sysID = '667fde881bd6bc9004bb1fc3b24bcb7a'; // APAC SSC SAP MDM Group
// }
// if (current.variables.request_type == 'Extend' && current.variables.what_company_code_are_you_extending.u_ssc == 'ZSGP') {
// sysID = '667fde881bd6bc9004bb1fc3b24bcb7a'; // APAC SSC SAP MDM
// } Comented for this ticket: GRQ0324499
if (current.variables.request_type == 'Modify' && current.variables.account_group != 'ZAUS') {
var nCountZGBR = 0;
var nCountZUSA = 0;
var nCountZSGP = 0;
var nCount = 0;
var sGroupSysID = '3e7fde881bd6bc9004bb1fc3b24bcbc0'; // EMEA SSC SAP MDM Group - Default Group SysID
var grSSC = new GlideRecord('u_sap_company_code_to_vendor');
grSSC.addQuery('u_vendor_number', current.variables.sap_vendor_number);
grSSC.query('u_active', true);
grSSC.query();
var grCount = grSSC.getRowCount();
while (grSSC.next()) {
nCount++;
if (grSSC.u_company_code.u_ssc == 'ZGBR') {
nCountZGBR = nCountZGBR + 1;
gs.info('EMEACount ' + nCountZGBR);
}
if (grSSC.u_company_code.u_ssc == 'ZUSA' || grSSC.u_company_code.u_ssc == 'ZUSI') {
nCountZUSA = nCountZUSA + 1;
gs.info('USCount ' + nCountZUSA);
}
if (grSSC.u_company_code.u_ssc == 'ZSGP') {
nCountZSGP = nCountZSGP + 1;
gs.info('APACCount ' + nCountZSGP);
}
}
if (nCountZGBR == nCount) {
sGroupSysID = '3e7fde881bd6bc9004bb1fc3b24bcbc0'; // EMEA SSC SAP MDM Group
} else if (nCountZUSA == nCount) {
sGroupSysID = '027f9e881bd6bc9004bb1fc3b24bcb71'; // US SSC SAP MDM Group
}
// if (current.variables.account_group == 'ZTRD' && current.variables.request_type == 'Modify') {
// workflow.info('Line 126 executed for ZTRD');
// sGroupSysID = '667fde881bd6bc9004bb1fc3b24bcb7a';
// }
var countryGroup = isPartOfsapCode(current.variables.company_code.getDisplayValue());
workflow.info('Country group is ' + countryGroup.toString());
if (current.variables.account_group == 'ZTRD') {
workflow.info('Line 132' + current.variables.request_type);
if (current.variables.account_group == 'ZTRD' && (current.variables.request_type == 'Modify' && countryGroup == '667fde881bd6bc9004bb1fc3b24bcb7a')) {
workflow.info('Line 134' + current.variables.request_type);
sGroupSysID = '667fde881bd6bc9004bb1fc3b24bcb7a'; //APAC SSC SAP MDM
} else {
workflow.info('Line 140' + current.variables.request_type);
sGroupSysID = '7f629a941b459d906b7ab165464bcbb5'; //APAC SSC SAP MDM ENG
}
}
//else if (nCountZSGP == nCount) {
// sGroupSysID = '667fde881bd6bc9004bb1fc3b24bcb7a'; // APAC SSC SAP MDM Group
// } Comented for this ticket: GRQ0324499
//Use the Group SysID variable sGroupSysID where required.
sysID = sGroupSysID;
}
workflow.info('Extend company code without SSC: ' + current.variables.what_company_code_are_you_extending);
workflow.info('Extend company code with SSC: ' + current.variables.what_company_code_are_you_extending.u_ssc);
var extendCompanyCodeGroup = isPartOfsapCode(current.variables.what_company_code_are_you_extending.getDisplayValue());
workflow.info('The Extend code is: ' + extendCompanyCodeGroup + 'Line 146' + current.variables.request_type);
if (current.variables.request_type == 'Extend') {
workflow.info('Extend group' + extendCompanyCodeGroup);
if( current.variables.account_group == 'ZTRD' && extendCompanyCodeGroup == '667fde881bd6bc9004bb1fc3b24bcb7a') {
workflow.info('Extend group 167' + extendCompanyCodeGroup);
workflow.info('Request type ' + current.variables.request_type + ' group returned: ' + extendCompanyCodeGroup);
sysID = '667fde881bd6bc9004bb1fc3b24bcb7a'; //APAC SSC SAP MDM
} else {
workflow.info('Extend group 171' + extendCompanyCodeGroup);
workflow.info('Line 172' + current.variables.request_type);
sysID = '7f629a941b459d906b7ab165464bcbb5'; //APAC SSC SAP MDM ENG
}
}
workflow.scratchpad.group = sysID;
current.assignment_group = sysID;
//Not best practice, should be in a system property.
current.business_service = 'a5b70f0ddbc0fb442cb33307f496192e'; //Finance (SAP) Services
current.u_service = '8bcf9d680f3b52007b3a3e7ce1050e4e'; // Purchase to Pay
current.u_application = '8da228addbe5fa80b82c79600f961953'; // P1 - Maintain Vendor Details
current.u_category = 'bdc925391b5d7f008d22c9506e4bcbc9'; // Other "Please specify in description"
}
function isPartOfsapCode(countryCode) {
workflow.info('The country code is: ' + countryCode);
var sGroupSysID = '3e7fde881bd6bc9004bb1fc3b24bcbc0';
var sysID = sGroupSysID;
var sapCodeENG = ["AU25", "HK05", "HK09", "IN15", "IN24", "SG01", "IN16", "SG05", "SG06", "SG14"];
var sapCode = ["JP04", "JP05", "JP06", "KR02", "KR03", "MY01", "MY02", "CN04", "CN10", "CN19", "TW02", "TW03"];
for (var sapCodeIndex = 0; sapCodeIndex < sapCode.length; sapCodeIndex++) {
//if (current.variables.company_code.u_company_code == sapCode[sapCodeIndex]) {
if (countryCode == sapCode[sapCodeIndex]) {
return '667fde881bd6bc9004bb1fc3b24bcb7a'; // APAC SSC SAP MDM
}
// }
}
for (var sapIndex = 0; sapIndex < sapCodeENG.length; sapIndex++) {
//if (current.variables.company_code.u_company_code == sapCodeENG[sapIndex]) {
if (countryCode == sapCodeENG[sapIndex]) {
return '7f629a941b459d906b7ab165464bcbb5'; // APAC SSC SAP MDM ENG
}
//}
}
}