- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2019 05:25 AM
I have this script that sets values on INC/CHG/PROB forms if field is empty. By customer requirement I wish to change it so that it allways overwrite values in form, but only if field is not empty in the CI it gets value from.
To sum it up. CI gets selected on incident form, it checks if CI has value in Ass group, category and subcategory and if it does overwrite values on Incident form. How should i alter below script ?
if (isLoading || newValue === '') {
return;
}
var ci = g_form.getReference('cmdb_ci', getci);
//Type appropriate comment here, and begin script below
}
function getci(ci){
if (g_form.getValue('category')== '' && ci.category !='')
{
g_form.setValue('category', ci.category);
}
if (g_form.getValue('subcategory')== '' && ci.subcategory !='')
{
g_form.setValue('subcategory', ci.subcategory);
}
if (g_form.getValue('assignment_group')== '' && ci.assignment_group !='')
{
g_form.setValue('assignment_group', ci.assignment_group);
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2019 01:41 AM
You need to have if conditions to check whether category on ci is empty or not
Try the below script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ci = g_form.getReference('cmdb_ci', getci);
//Type appropriate comment here, and begin script below
}
function getci(ci){
if (ci.category !='')
{
g_form.setValue('category', ci.category);
}
if (ci.subcategory !='')
{
g_form.setValue('subcategory', ci.subcategory);
}
if (ci.assignment_group !='')
g_form.setValue('assignment_group', ci.assignment_group); {
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2019 01:41 AM
You need to have if conditions to check whether category on ci is empty or not
Try the below script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ci = g_form.getReference('cmdb_ci', getci);
//Type appropriate comment here, and begin script below
}
function getci(ci){
if (ci.category !='')
{
g_form.setValue('category', ci.category);
}
if (ci.subcategory !='')
{
g_form.setValue('subcategory', ci.subcategory);
}
if (ci.assignment_group !='')
g_form.setValue('assignment_group', ci.assignment_group); {
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2019 04:19 AM
Solved it. Thank you 🙂