The CreatorCon Call for Content is officially open! Get started here.

While giving None in the field mandatory is not happening in catalog

keerthi19
Tera Guru

Hi ,

I have 2 field and it has dependency . script below

function onChange(control, oldValue, newValue, isLoading) {

if (isLoading || newValue == '') {

g_form.clearOptions('Sample2');

g_form.clearValue('Sample2');

    }

    var ostype = g_form.getValue('os_type');

g_form.clearOptions('os_version');

  if (Sample1 == 'win')

  {

  g_form.addOption('Sample2','field1','Field1');

  g_form.addOption('Sample2', 'fiel2','Fiel2');

    }

else if(Sample1 == 'linux'){

                      g_form.addOption('Sample2', 'field3','Field3');

}

So i am adding option based on the value selection .And each Sample1 and Sample2 as mandatory an it include None .

If i am selecting option from sample1 its taking values based on my selection in sample2 but   if i give none in sample1 its not selecting None in sample2 instead its coming as blank field. Due to that mandatory is not happening. Anyone has any suggestion?

Thanks

6 REPLIES 6

akaupisch
Kilo Guru

you need to get the value from the field you are using as the dependency. As I see it, you are basing things on sample1s data...



So you need var osType = g_form.getValue('Sample1')



then on the if statements do



if (osType == 'win')


else if (osType == 'linux')



edit:



Or conversely, you could change the ostype variable name to be:



var Sample1 = g_form.getValue('os_type')


then Sample1 will equal something in the if statements


and that'll work, but you shouldn't start vars with a capital.


Hi Adam,.


Sorry ignore my previous script.its been wronly pasted.below is right script



if (isLoading || newValue == '') {



g_form.clearOptions('sample2');


g_form.clearValue('sample2');



    }




    var sample1=g_form.getValue('sample1);



g_form.clearOptions('sample2');



  if (sample1 == 'win')


  {



  g_form.addOption('sample2','field1','Field1');


  g_form.addOption('sample2', 'fiel2','Fiel2');



    }


else if(sample1 == 'linux'){



                      g_form.addOption('sample2', 'field3','Field3');


}


since you are clearing the options you need to add none back as an option add the following to your list of options... obviously replace v_application with your field name.




g_form.addOption('v_application', '', '--None--');


Hi Raymond,


If I do that I am getting two in the field and also its not making mandatory the after none selection in sample1.


Example:


If am selecting   sample1 as field1 then my next selection I am selecting none in sample1 ,so here its clearing the sample2 values but field is remains blank its not making mandatory again. since there is no value it should make the field mandatory but its not making it. Instead its showing blank and if I go and click that field None is present .when I   go select none at time its making field as mandatory.this should not happen.


Automatically when we select sample1 as none the sample2 also goes to none and it should make field mandatory. But its not behaving like that.that is the issue.