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

Script Library

  Convert an integer field to a Lookup field
 
  chubbard posted this script:
  Inspired by Tamra's contribution:
    http://support.westside.com/support/scriptLib/sDetails.view?rowid=55
here's a script that converts an integer field to a lookup field. Handy if you've decided afterwards that you want a bound set of values. Note that you should delete and re-add the field in any views that use it.

// This function converts a field of type integer to type lookup.
// Arguments:
// strTable: The name of the table that contains the field.
// strField: The name of the integer field to convert.
// strLookupTable: The name of the table this will lookup
// strLookupDisplayField: The name of the field that will be displayed

webcall function convertFieldToLookup(strTable, strField,
        strLookupTable, strLookupDisplayField)
{
    var fld = web.tables.Fetch(strTable).fields.fetch(strField);
    if(fld.type == "Integer")
        {
        var obj = new Object();
        obj.lookupTable = strLookupTable;
        obj.displayField = strLookupDisplayField;
        fld.setProperties(obj);
        return "The " + strField + " field in the " + strTable
            + " table has been converted to type Lookup for table "
            + strLookupTable
            + " with display field " + strLookupDisplayField;
        }
    else
        throw("The " + strField + " field in the " + strTable +
            " table is not an Integer field.");
}
 
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