Tip on checking existance of records..

Tip on checking existance of records..

So I don't know about you, but I get really tired of having to use the count function to check for the existence of records first before making a collection. (From my knowledge this is how most do it) Example...

  1. cnt = count(myForm[field == value]);
  2. if(cnt != 0)
  3. {
  4.    myRecords = myForm[field == value];
  5. }

One must use the count function because if you try to do this, ZC throws an error

  1. myRecords = myForm[field == value];
  2. info myRecords.ID;

However, I've found what I think is a very convenient way of testing for records..

  1. myRecords = myForm[field == value];
  2. if(myRecords.ID.getAll().size() != 0)
  3. {
  4.       info myRecords.ID;
  5. }

getALL() nerfs the error turning a blank "NVIEW" into an BIGINT list of ID's. I've always used getAll but I've never thought of trying it on a blank collection.

Hope this is helpful to others. BTW, if another developer has a way to mitigate collection errors WITHOUT having to restate your collection query. Let me know ;)

Stephen Rhyne