onLoad Client Scripts execute script logic when forms are loaded. Use onLoad Client Scripts to manipulate a form’s appearance or content. For example, setting field or form-level messages based on the presence of a value. Use onLoad Client Scripts sparingly as they impact form load times.
Requirement :
Make CI field mandatory when state is in progress and make the Service field mandatory when the state is on hold.
function onLoad() {
//Type appropriate comment here, and begin script below
var s = g_form.getValue('state');
if (s == 2) {
g_form.setMandatory('cmdb_ci', true);
} else if (s == 3) {
g_form.setMandatory('business_service', true);
}
}