- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 02:57 AM
Good afternoon. I have a requirement on a Catalog Form.
When Request type is Modify and Account group is ZTRD, then it should check the below company code:
AU, IN, HK, SG company code should assign to APAC SSC SAP MDM ENG Assignment group
CN, KR, TW, MY, JP company code should assign to APAC SSC SAP MDM Assignmentgroup
but when Request Type is Modify and account group as ZTRD, for any company code, it by default setting APAC SSC SAP MDM ENG.
Please check this code and rectify this issue.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 04:07 AM
try this
setGroup();
function setGroup() {
var sysID = '';
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"];
// EMEA Region conditions
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
if (current.variables.request_type == 'Modify' && current.variables.account_group == 'ZTRD') {
var companyCode = current.variables.company_code.u_company_code;
if (sapCodeENG.includes(companyCode)) {
sysID = '7f629a941b459d906b7ab165464bcbb5'; // APAC SSC SAP MDM ENG
} else if (sapCode.includes(companyCode)) {
sysID = '667fde881bd6bc9004bb1fc3b24bcb7a'; // APAC SSC SAP MDM
}
}
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"
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 03:22 AM
Good job adding the logs, add some more, and share which ones you are getting or not getting that you are expecting, rather than us trying to digest and discern this entire script. Each value used in if conditions (like current.variables.company_code.u_ssc) should be logged, and a log inside each if condition if you are unsure if the script in the if blocks is being executed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 04:07 AM
try this
setGroup();
function setGroup() {
var sysID = '';
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"];
// EMEA Region conditions
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
if (current.variables.request_type == 'Modify' && current.variables.account_group == 'ZTRD') {
var companyCode = current.variables.company_code.u_company_code;
if (sapCodeENG.includes(companyCode)) {
sysID = '7f629a941b459d906b7ab165464bcbb5'; // APAC SSC SAP MDM ENG
} else if (sapCode.includes(companyCode)) {
sysID = '667fde881bd6bc9004bb1fc3b24bcb7a'; // APAC SSC SAP MDM
}
}
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"
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2025 09:25 PM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2025 03:52 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader