Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2024 07:17 AM
kb_knowledge_base is a reference field. It has a field title, I need to compare that field.
I'm getting an undefined error. Below is the code.
function onLoad() {
//Type appropriate comment here, and begin script below
var kbase = g_form.getReference('kb_knowledge_base', getTitle);
var type = g_form.getValue('u_type');
var kbase1;
function getTitle(kbase) {
kbase1 = kbase.title;
}
alert('KBase selected is ' + kbase1);
if (kbase1 == 'IT' && type == 'standard') {
g_form.setMandatory('cmdb_ci', false);
} else
g_form.setMandatory('cmdb_ci', true);
}
Any one has any idea why this is not working.
Thank you,
shedheesh
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2024 07:21 AM
Hi @Shidhi
Please try this code:
function onLoad() {
g_form.getReference('kb_knowledge_base', getTitle);
}
function getTitle(kbase) {
var kbase1 = kbase.title;
var type = g_form.getValue('u_type');
alert('KBase selected is ' + kbase1);
if (kbase1 == 'IT' && type == 'standard') {
g_form.setMandatory('cmdb_ci', false);
} else {
g_form.setMandatory('cmdb_ci', true);
}
}
Thanks and Regards
Sai Venkatesh
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2024 07:21 AM
Hi @Shidhi
Please try this code:
function onLoad() {
g_form.getReference('kb_knowledge_base', getTitle);
}
function getTitle(kbase) {
var kbase1 = kbase.title;
var type = g_form.getValue('u_type');
alert('KBase selected is ' + kbase1);
if (kbase1 == 'IT' && type == 'standard') {
g_form.setMandatory('cmdb_ci', false);
} else {
g_form.setMandatory('cmdb_ci', true);
}
}
Thanks and Regards
Sai Venkatesh

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2024 07:32 AM
@Shidhi Try the following
function onLoad() {
//Type appropriate comment here, and begin script below
var kbase = g_form.getReference('kb_knowledge_base', getTitle);
var type = g_form.getValue('u_type');
var kbase1;
function getTitle(kbase) {
kbase1 = kbase.title;
alert('KBase selected is ' + kbase1);
if (kbase1 == 'IT' && type == 'standard') {
g_form.setMandatory('cmdb_ci', false);
} else {
g_form.setMandatory('cmdb_ci', true);
}
}
}