- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2024 10:08 AM
Hello,
I have a request which requires the Client Script Below to be changed with a condition that will not run the part that is magenta that sets the business area as highlighted in the screen shot below. Currently, the script below populates everything on the left side and the business area on the right side on the screen shot below when this is a new case based on the cost center of the Risk analyst.
When another user with a specific role opens the case, they are able to change the Risk Analyst, this in turn is changing the Business Area field, which I want to stay as is. I have tried a few variations with no luck yet. So any help would be greatly appreciated.
Client Script:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2024 12:08 PM
Then something like this should work:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('clientUtilsCustom');
ga.addParam('sysparm_name', 'getUserDetails');
ga.addParam('sysparm_nm', newValue);
ga.getXMLAnswer(getResp);
}
function getResp(response) {
if (response != 'false') {
var dat = response.split(',');
g_form.setValue('user_name', dat[0]);
if (g_form.getValue('business_area') == '') {
var cost_center = dat[1];
var bav = '';
if (cost_center == '6052') {
bav = 'Retail(Cost Center 6052)';
} else if (cost_center == '0714') {
bav = 'COR Support (Cost Center 0714)';
} else if (cost_center == '6053') {
bav = 'Digital (Cost Center 6053)';
} else if (cost_center == '1043') {
bav = 'TCC Sales (Cost Center 1043)';
} else if (cost_center == '0198') {
bav = 'TCC Lending (Cost Center 0198)';
} else if (cost_center == '0734') {
bav = 'TCC Business (Cost Center 0734)';
}
g_form.setValue('business_area', bav);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2024 11:27 AM
Hi Annette,
Is it fair to summarize the use case to say that you only want to populate the Business Area field if it is blank - such as when this is a new case, but when someone changes the Risk Analyst manually, and the Business Area is already populated, it should not change?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2024 11:38 AM
Yes, exactly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2024 12:08 PM
Then something like this should work:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('clientUtilsCustom');
ga.addParam('sysparm_name', 'getUserDetails');
ga.addParam('sysparm_nm', newValue);
ga.getXMLAnswer(getResp);
}
function getResp(response) {
if (response != 'false') {
var dat = response.split(',');
g_form.setValue('user_name', dat[0]);
if (g_form.getValue('business_area') == '') {
var cost_center = dat[1];
var bav = '';
if (cost_center == '6052') {
bav = 'Retail(Cost Center 6052)';
} else if (cost_center == '0714') {
bav = 'COR Support (Cost Center 0714)';
} else if (cost_center == '6053') {
bav = 'Digital (Cost Center 6053)';
} else if (cost_center == '1043') {
bav = 'TCC Sales (Cost Center 1043)';
} else if (cost_center == '0198') {
bav = 'TCC Lending (Cost Center 0198)';
} else if (cost_center == '0734') {
bav = 'TCC Business (Cost Center 0734)';
}
g_form.setValue('business_area', bav);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2024 01:27 PM
Thank you, I thought it was just another line of code, but I wasn't sure where exactly to place it.