Page 1 of 1

nubeforeSave or other function?

Posted: Fri Oct 28, 2011 10:31 am
by johan
Hi,

I'm looking for a sollution to check the things filled in on my subform.

When the user select p.ex. item with code '100' (whith the lookup) he also need to select item '110'

I want to get an alert before safe when item 100 is selected but item 110 is missing.

How to get it work?

Thanks

Johan

Re: nubeforeSave or other function?

Posted: Mon Oct 31, 2011 3:46 am
by admin
johan,

I haven't tested it but this should work for you..

Code: Select all


function nuBeforeSave(){

   if(hasValue('100') && !hasValue('110')){
      alert('110 needs to be added');
      return false;
   }else{
      return true;
   }


}

function hasValue(pCode){

   var sfName = 'thesubform';  //-- the subform name to look in
   var fdName = 'thefield';    //-- the field name to look in
   var ar     = Array();
   ar         = nuSubformRowArray('FMinvoice_item');
   
   for(var i = 0 ; i < ar.length ; i++){
      if(document.getElementById(ar[i] + fdname).value == pCode){
         return true;
      }
   }

   return false;
}   


Steven

Re: nubeforeSave or other function?

Posted: Mon Oct 31, 2011 9:23 am
by johan
Steven,
You're great,

It works

Thanks a lot

Johan

Re: nubeforeSave or other function?

Posted: Mon Oct 31, 2011 10:30 pm
by admin
.