Question on client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 06:50 AM
Hi All,
I have written on change client script for populating category nd subcategory based on the caller company, department and caller email domain.
res[0] - is company and res[2] - is department & res[1] - is email domain
if ((res[0] == 'ES'|| res[0] == 'RES'&& (res[2] != " Business Servic" || res[2] != "Accounts " || res[2] != ' Marketing' || res[2] != " Property Mgmt" || res[2] != " Team")) && (res[1] == 'textiand' || res[1] == 'ddLife')) {
Here in my case if i give only one company then my code is working fine but here i want to take two companies
ie, if i take resi[0]=='ES', then the code is working fine, but i need to take 2 companies here,
Please find the below code i have written :
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
//alert('#test');
try {
//alert('hi:::::' + newValue);
if ( newValue === '') {
return;
}
//jslog('hi');
//alert("new value is ::" + newValue);
var resFlag = false;
var userSysid = g_form.getValue('caller_id');
var ga = new GlideAjax('Incident_caller_details');
ga.addParam('sysparm_name', 'get_callerdetails');
ga.addParam('sysId', userSysid);
ga.getXML(HelloWorldParse);
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
//alert(answer);
var res = answer.split(',');
if(res[2] == "Property Mgmt")
{
return;
}
if ((res[0] == 'ES'|| res[0] == 'RES'&& (res[2] != " Business Servic" || res[2] != "Accounts " || res[2] != ' Marketing' || res[2] != " Property Mgmt" || res[2] != " Team")) && (res[1] == 'textiand' || res[1] == 'ddLife')) {
/
alert('inside the right block');
g_form.removeOption('category', 'Application');
g_form.removeOption('category', 'Building Maintenance');
}
if (res[0] != 'ES'&& res[0] != 'RES') {
alert('inside the right block :: Non resal');
g_form.addOption('category', 'Application', 'Application');
g_form.addOption('category', 'Building Maintenance','Building Maintenance');
}
if ((res[0] == 'ES' ||res[0] == 'RES' && (res[2] == " Business Servic" || res[2] == "Accounts " || res[2] == ' Marketing' || res[2] == " Property Mgmt" || res[2] == "Team")))
{
alert('inside the right block :: Ri corp');
g_form.addOption('category', 'Application', 'Application');
g_form.addOption('category', 'Building Maintenance','Building Maintenance');
}
}
} catch (ex) {
//jslog('A JavaScript runtime error occurred: ' + ex.message);
}
//Type appropriate comment here, and begin script below
}
Could you please help me on to get the proper solution.
Thanks,
Manish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 06:58 AM
I'm not sure I'm following, are you saying that this doesn't yield the correct results
if ((res[0] == 'ES'|| res[0] == 'RES'&& (res[2] != " Business Servic" || res[2] != "Accounts " || res[2] != ' Marketing' || res[2] != " Property Mgmt" || res[2] != " Team")) && (res[1] == 'textiand' || res[1] == 'ddLife')) {
But this does?
if ((res[0] == 'ES' && (res[2] != " Business Servic" || res[2] != "Accounts " || res[2] != ' Marketing' || res[2] != " Property Mgmt" || res[2] != " Team")) && (res[1] == 'textiand' || res[1] == 'ddLife')) {
