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

Script Library

  Convert an integer field to a Lookup field
  chubbard posted this script:
  Inspired by Tamra's contribution:
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;
        return "The " + strField + " field in the " + strTable
            + " table has been converted to type Lookup for table "
            + strLookupTable
            + " with display field " + strLookupDisplayField;
        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    
Email Us