Pandora - Sample - Company Name Duplicate Check

From SmartWiki
Revision as of 13:35, 29 January 2011 by Cameron (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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