Notifications

37 views

Description

In situation where we want to set value of a choice field based on the String fields(ex. Short Description) using client script below onload client script can be useful

Instructions


In below example, Urgency and Impact fields are set on load of form based on the specific string in Short Description field

function onLoad() {

    var desc = g_form.getValue('short_description');
    desc = desc.toLowerCase();
  //  alert(desc);

    if (desc.indexOf('critical') >= 0) {
        g_form.setValue('impact', '1');
        g_form.setValue('urgency', '1');
    } else if (desc.indexOf('major') >= 0) {
        g_form.setValue('impact', '2');
        g_form.setValue('urgency', '2');
    } else if (desc.indexOf('minor') >= 0) {
        g_form.setValue('impact', '3');
        g_form.setValue('urgency', '3');
    } else if (desc.indexOf('warning') >= 0) {
        g_form.setValue('impact', '4');
        g_form.setValue('urgency', '4');
    }
}

Article Information

Last Updated:2020-08-11 04:15:12
Published:2020-08-11