Search these areas:
Support Forums
Product Info

-DataWeb: What's New
-Creating an Application
-The DataWeb Designer
-Application Management
-Data Tables
-Data Tables
-Data Analysis
-Object Model
-Full-Text Search
-Domain and Email Hosting
-HotBlock Modules
-Account Management
-New Responsive UI Module

DataWeb Help
Support Forums
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:

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( )
  companyID = rs.rowid;
  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.

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