Difference between revisions of "Pandora - Sample - Company Name Duplicate Check"

From SmartWiki
Jump to: navigation, search
 
(One intermediate revision by the same user not shown)
Line 10: Line 10:
 
   var qryfields = "name";
 
   var qryfields = "name";
 
   var qryfilter = " name='"+frm.cname.value.replace(/'/g,"\\'")+"'";
 
   var qryfilter = " name='"+frm.cname.value.replace(/'/g,"\\'")+"'";
   var rs = company_find(false,'',qryfields,qryfilter,'name',0,200,'');
+
   var rs = company_find(false,'',qryfields,qryfilter,'',0,5,'');
 
   if(rs.recordcount>0){
 
   if(rs.recordcount>0){
 
       alert("An organization with that name already exists. Please enter a unique name.");
 
       alert("An organization with that name already exists. Please enter a unique name.");

Latest revision as of 13:35, 29 January 2011

The following script can be used on the company page to ensure there are no other companies with the same name already present in the system.

It also replaces any quotation marks within the name with an apostrophe.

function savefunc(frm){
ss_developer_key="123456-4BjBBeH3oYVbBYgNX/E=";
frm.cname.value=frm.cname.value.replace(/"/g,"'");
if("@name@"!=frm.cname.value){
   var qryfields = "name";
   var qryfilter = " name='"+frm.cname.value.replace(/'/g,"\\'")+"'";
   var rs = company_find(false,'',qryfields,qryfilter,'',0,5,'');
   if(rs.recordcount>0){
      alert("An organization with that name already exists. Please enter a unique name.");
      return false;
   }
}
return true;
}

See Also