Number of records returned from READ

Posted by Roger Blanchard on 15-May-2014 14:26

When invoking a service (read operation) is there a way to determine how many records were returned?

I have a page where I am scanning a barcode and then invoking the read service. If the barcode is fetched from the DB my controls are populated with the record info. However, if the barcode does not find a matching record in the DB all my controls on the page say 'undefined'. I would like to trap the results in the service success event and pop an error then clear the undefined.

All Replies

Posted by johncat on 20-May-2014 04:35

Will

   data.dsXxxx.ttXxxxx.length

do it?  My app won't play ball at the moment, so I can't test it, but I think that should work.

Posted by Roger Blanchard on 20-May-2014 10:01

Kind of.

If records are actually contained in ttItem then data.dsItem.ttItem.length will return the number of records. If no records are returned I will get the following error.

Uncaught TypeError: Cannot read property 'length' of undefined

Posted by Roger Blanchard on 20-May-2014 10:07

If I use if (data.dsItem.ttItem === undefined) then I can trap it.

Thanks.

This thread is closed