Search these areas:
Help
Support Forums
Product Info



-Introduction
-DataWeb: What's New
-Creating an Application
-The DataWeb Designer
-Application Management
-Data Tables
-Data Tables
-Views
-Templates
-Components
-Data Analysis
-Members
-Security
-Importing
-Exporting
-FTP
-JavaScript
-Object Model
-Full-Text Search
-Domain and Email Hosting
-HotBlock Modules
-Account Management
-Glossary
-New Responsive UI Module





DataWeb Help
Support Forums
Tutorial
Script Library
Knowledge Base

Home > Support

Support Forum



Add option if record is not in lookup table
lfambles asked:
Is there a simple way to add a record to a table if there is not a record in that table for a lookup field? For example, I am generating invoices and one field is a look up of companies from the companies table. If the company that is being invoiced is not in the companies table, I need the option of adding it so that I don't have to exit the process and add a record to the companies table.  
  dougl responded:
  Certainly.

First check to see if the company is in the company table. If it is, assign companyID it's rowid value. If it isn't, insert a new company record and assign companyID the rowid value of the newly inserted record.

var companyID;
var rs = new Resultset( "company", "rowid", "name = '" + companyName + "' );
if( rs.next() )
  companyID = rs.rowid;
else
  companyID = table.insert( "company", {name:companyName} ).rowid;
 
  dougl responded:
  DataWeb considers this issue closed.
If you have additional questions or comments about this issue, please open it again.
If you have questions about a different topic please open a new support question.

Thanks,
DataWeb Support
 
  Please Log On
or create your own DataWeb Account.
Affiliate | Partner | Terms of Use | Privacy Policy | Contact Us | Pricing | Bring DataWeb In-House    
DataWeb, 720 North 10th Street, A #145, Renton, Washington 98057 *425-583-5970* Fax 484-770-4706* Email Us