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

filtering lookups from table.Select / cmdSelect
mike asked:
I'm trying to filter on a lookup field using either table.Select or cmdSelect (both ways give the same error message).

If I do:

   var rs ="roster", fields, "g=3", "lastname");

then I get an error in the log.  However if I use:

   var rs ="roster", fields, "g:rowid=3", "lastname");

then it works as expected.  (I.e., g is a lookup field with PK of rowid).  When I use the slightly shorter syntax for filtering views it works fine, but not from code.

Is this just how it is, or is there something more subtle going on here that I'm missing?  Thanks!
  dougl responded:
  I know:

var rs = "roster", fields, {g:3}, "Lastname" );

will work.

I wonder if "?g~eq=3" will work?

I'll investigate further as to why plain filter syntax like "g=3" doesn't work. Hopefully my work-around will keep you developing while I research a better answer.
  mike responded:
  Thanks. FYI, its not urgent as "g:rowid=3" is perfectly good workaround. Unfortunately it took me a while to find it...  
  dougl responded:
  Cool. I'm still curious. I have a hard time negotiating our many filter syntaxes.

A question open to you and anyone else monitoring this conversation:
Which filter syntax do you prefer in script? How do you prefer to construct your resultset filters?
  dougl responded:
  For simple filters, I prefer
{fieldName:value} and "fieldName=value" (mostly "*", to tell the truth).

I'm currently writing a script with the following filter:
strFieldName + ">=" + iLowVal + " AND " + strFieldName "<" + iHighVal
but I'd be lost without help on for this one.
  brendanx responded:
  I tend to use {fieldName:value} for simple filters as well, mostly because I don't have to mess with quoting strings, and forgetting a + in a string concatenation:

"fieldName = '" + value + "'"

Only when I need something that is not possible with the object literal syntax (OR, <, >, <>, LIKE, etc.) do I resort to the SQL string syntax.  I never use the URL syntax in code.
  matthewb responded:
  Let me throw out a theory.  If 'g' is a user field (or if the RowId is not the primary key of the other table) then "g=3" would not be the same as "g:rowid=3"

It it were a user field for instance g would be a userid (string).
  matthewb responded:
  Mystery solved.  To make the description simpler, you left out one key piece of information.  The column name is "group" (not "g").  GROUP is a SQL keyword and so must be bracketed.


I promise that in v2 the scripting objects will do  better job of reporting data errors.  I will make sure the list of reserved words are added to
  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