Catalog Client Script - OnChange - Remove Mandatory Field if Assignment Group Changes

Mark Lanning
Tera Guru

Trying to use a Catalog Client Script - OnChange

 

When Catalog Task is Created will want variable set to mandatory

If Task Assignment Group is Changed, want to remove the variable mandatory.

 

UI Type - ALL

Applies on Catalog Tasks is Checked

 

Been trying to use this script, but not working.

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    //Type appropriate comment here, and begin script below  
   
    var group = g_form.getValue('assignment_group');
            if (newValue != oldValue)
            {
                alert('Assignment Group Changed');
                g_form.setMandatory('should_this_go_to_the_committee_to_assign_more_groups', false);
                return true;
    }
}

 

3 REPLIES 3

Weird
Mega Sage

So "should_this_go_to_the_committee_to_assign_more_groups" is a variable and it's mandatory by default?
Is the mandatory set on variable record or by a client script or a UI policy?

There's a certain run order on things.
Client scripts -> UI policies -> Variable record values.
So if you have a client script that says "setMandatory('field', true)" and a UI policy that sets it false, the UI policy overwrites the client script.
If you have "mandatory" or "read only" field set true on the variable the client scripts and ui policies won't overwrite it. You'd have to set the field to false and then create a client script or UI policy to handle setting it to true normally.

Mark Lanning
Tera Guru

Thank You Mega,

It turned out it was the type of Client Script I was using - Catalog Client Script vs Client Script.

 

SunilKumar_P
Giga Sage

Hi @Mark Lanning, Catalog task field (Ex- State) values can be accessed using the Client Scripts where as the catalog variables (Ex- should_this_go_to_the_committee_to_assign_more_groups) are accessed in the Catalo Client Scripts. As per my knowledge, it is not feasible to manage the varaibles (like making variable mandatory) based on the state of catalog task.

 

Regards,
Sunil