Applies on a Catalog Item view Applies on Requested Items Applies on Catalog Tasks

rajeshraji1
Tera Expert

Hi ,i have created client script and some variables but its not work in catalog task view kindly suggest and i have selected global checkbox true for all the variables and script as well.

 

on change code 

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

        g_form.setVisible('box1',false);
    g_form.setVisible('box1_add',false);
    g_form.setVisible('box2',false);
    g_form.setVisible('box2_add',false);
    g_form.setVisible('box3',false);
    g_form.setVisible('box3_add',false);
    g_form.setVisible('box4',false);
    g_form.setVisible('box4_add',false);
      return;
   }
   

   if(newValue == '0' ){
    g_form.setVisible('box1',false);
    g_form.setVisible('box1_add',false);
    g_form.setVisible('box2',false);
    g_form.setVisible('box2_add',false);
    g_form.setVisible('box3',false);
    g_form.setVisible('box3_add',false);
    g_form.setVisible('box4',false);
    g_form.setVisible('box4_add',false);
   }      
var a=g_form.getValue('select');

if(a == '1'){
        g_form.setVisible('box1',true);
    g_form.setVisible('box1_add',true);
    g_form.setVisible('box2',false);
    g_form.setVisible('box2_add',false);
    g_form.setVisible('box3',false);
    g_form.setVisible('box3_add',false);
    g_form.setVisible('box4',false);
    g_form.setVisible('box4_add',false);
}else {
        g_form.clearValue('box1');
        g_form.clearValue('box1_add');
   }

if(a == '2')
{
g_form.setVisible('box1',true);
    g_form.setVisible('box1_add',true);
    g_form.setVisible('box2',true);
    g_form.setVisible('box2_add',true);
    g_form.setVisible('box3',false);
    g_form.setVisible('box3_add',false);
    g_form.setVisible('box4',false);
    g_form.setVisible('box4_add',false);

}   else {
        g_form.clearValue('box1');
        g_form.clearValue('box1_add');
        g_form.clearValue('box2');
        g_form.clearValue('box2_add');
   }



 if(a == '3')
{
g_form.setVisible('box1',true);
    g_form.setVisible('box1_add',true);
    g_form.setVisible('box2',true);
    g_form.setVisible('box2_add',true);
    g_form.setVisible('box3',true);
    g_form.setVisible('box3_add',true);
    g_form.setVisible('box4',false);
    g_form.setVisible('box4_add',false);

}    
 else {
        g_form.clearValue('box1');
        g_form.clearValue('box1_add');
        g_form.clearValue('box2');
        g_form.clearValue('box2_add');
        g_form.clearValue('box3');
        g_form.clearValue('box3_add');
   }

 
}
3 REPLIES 3

JenniferRah
Mega Sage

Is this a Catalog Client Script? If so, you should have some checkboxes like these that will determine when it's used:

JenniferRah_0-1745426238082.png

 

Also, I see you are setting visibility of fields within the client script. The best practice is to use UI Policies for that.

Chaitanya ILCR
Kilo Patron

Hi @rajeshraji1 

try this out 

function onChange(control, oldValue, newValue, isLoading) {
    if (newValue == '') {

        g_form.setDisplay('box1', false);
        g_form.setDisplay('box1_add', false);
        g_form.setDisplay('box2', false);
        g_form.setDisplay('box2_add', false);
        g_form.setDisplay('box3', false);
        g_form.setDisplay('box3_add', false);
        g_form.setDisplay('box4', false);
        g_form.setDisplay('box4_add', false);
        return;
    }


    if (newValue == '0') {
        g_form.setDisplay('box1', false);
        g_form.setDisplay('box1_add', false);
        g_form.setDisplay('box2', false);
        g_form.setDisplay('box2_add', false);
        g_form.setDisplay('box3', false);
        g_form.setDisplay('box3_add', false);
        g_form.setDisplay('box4', false);
        g_form.setDisplay('box4_add', false);
    }
    var a = g_form.getValue('select');

    if (a == '1') {
        g_form.setDisplay('box1', true);
        g_form.setDisplay('box1_add', true);
        g_form.setDisplay('box2', false);
        g_form.setDisplay('box2_add', false);
        g_form.setDisplay('box3', false);
        g_form.setDisplay('box3_add', false);
        g_form.setDisplay('box4', false);
        g_form.setDisplay('box4_add', false);
    } else {
        g_form.clearValue('box1');
        g_form.clearValue('box1_add');
    }

    if (a == '2') {
        g_form.setDisplay('box1', true);
        g_form.setDisplay('box1_add', true);
        g_form.setDisplay('box2', true);
        g_form.setDisplay('box2_add', true);
        g_form.setDisplay('box3', false);
        g_form.setDisplay('box3_add', false);
        g_form.setDisplay('box4', false);
        g_form.setDisplay('box4_add', false);

    } else {
        g_form.clearValue('box1');
        g_form.clearValue('box1_add');
        g_form.clearValue('box2');
        g_form.clearValue('box2_add');
    }

    if (a == '3') {
        g_form.setDisplay('box1', true);
        g_form.setDisplay('box1_add', true);
        g_form.setDisplay('box2', true);
        g_form.setDisplay('box2_add', true);
        g_form.setDisplay('box3', true);
        g_form.setDisplay('box3_add', true);
        g_form.setDisplay('box4', false);
        g_form.setDisplay('box4_add', false);

    } else {
        g_form.clearValue('box1');
        g_form.clearValue('box1_add');
        g_form.clearValue('box2');
        g_form.clearValue('box2_add');
        g_form.clearValue('box3');
        g_form.clearValue('box3_add');
    }
}

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

rajeshraji1
Tera Expert

Hi,

 

can you suggest any simplest way to archive this scenario with mandatory option ?