how to prevent subject person being populated when opened for is changed

service buzz
Tera Contributor

Hi 

 

On HR Case form when I am trying to change the opened for  ,the subject  person is also getting populated with same opened for field value which should not happen in our requirement

 

Can you pls suggest how to proceed further as I understand its ooB behaviour

4 REPLIES 4

Shruti
Mega Sage
Mega Sage

Hi,

Make the OOB client script inactive "Auto populate subject person"

Shruti_0-1709632750376.png

 

You are right but I cannot make it inactive I want this script not to run for one of the hr serviceS ,I tried to add condition  in the script but it doesn't work out 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '' || (typeof g_aw !== 'undefined' && g_form.isNewRecord()))
return;
 
var hrservice = g_form.getValue("hr_service");
if (hrservice != 'Vision Benefits Inquiry'){
var subjectPerson = g_form.getValue("subject_person");
g_form.getReference('hr_service', setSubjectPerson);
}
 
function setSubjectPerson(serviceGr) {
var DO_NOT_DEFAULT_SUBJECT_PERSON = '5ad4d1709f402200d9011977677fcfbb';
if(!subjectPerson && !serviceGr || (serviceGr && String(serviceGr.case_options).indexOf(DO_NOT_DEFAULT_SUBJECT_PERSON)=== -1 )) 
g_form.setValue("subject_person",g_form.getValue("opened_for"));
}
}

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '' || (typeof g_aw !== 'undefined' && g_form.isNewRecord()))
        return;

    if (g_form.getValue('hr_service') != 'bf0db1099f231200d9011977677fcf3d') {
        var subjectPerson = g_form.getValue("subject_person");
        g_form.getReference('hr_service', setSubjectPerson);
    }

    function setSubjectPerson(serviceGr) {
        var DO_NOT_DEFAULT_SUBJECT_PERSON = '5ad4d1709f402200d9011977677fcfbb';
        if (!subjectPerson && !serviceGr || (serviceGr && String(serviceGr.case_options).indexOf(DO_NOT_DEFAULT_SUBJECT_PERSON) === -1))
            g_form.setValue("subject_person", g_form.getValue("opened_for"));
    }
}

service buzz
Tera Contributor

I added DO_NOT_DEFAULT_SUBJECT_PERSON  under case options for a particular HR Service and it worked.

Thanks for your assistance.