Catalogue Client Script not auto populating fields on catalogue item
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
In ServiceNow, I'm trying to develop an onLoad Client Script that will pre-populate the details of the following fields from a business application depending on if they meet a certain criteria:
I'm using the following code in my onLoad client script if the 'IBP Tier' field of a business application is A:
function onLoad() {
var draft = g_form.getValue('drafted');
var cbp = g_form.getValue('cbp_tier');
var l2 = g_form.getValue('u_availability_regulatory_less_than_2_hours');
var l2rat = g_form.getValue('rationale_2_hrs');
if (cbp == 'Tier A') {
alert('MH Value of L2 is ' + l2);
alert('MH Value of L2rat is ' + l2rat);
alert('MH Value of CBP is ' + cbp);
if (l2 != '') {
alert('L2 is not empty' + l2);
if ((l2 != 5 || l2 != 4) && l2 != '') {
setAllValues(5;
}
else{
setAllValues5);
}
}
}
function setAllValues(val) {
g_form.setValue('u_availability_regulatory_less_than_4_hours', val);
g_form.setValue('u_availability_regulatory_less_than_24_hours', val);
g_form.setValue('u_availability_regulatory_more_than_24_hours', val);
g_form.setValue('u_availability_regulatory_less_than_2_hours', val);
}
}
However, when I load my catalogue item with that client script, the following occurs:
The values of the four fields remain exactly the same. I'm expecting all of them to be updated to 'Severe' or '5' as the field 'Regulatory and Legal: Less than 2 Hours' is not 'Severe' or 'Material'
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi,
Theres typos in this part of the script
if ((l2 != 5 || l2 != 4) && l2 != '') {
setAllValues(5;
}
else{
setAllValues5);
}
