utils.hasRecords(record, [qualifiedRelationString]) in calcs

It used to be that if you did this:

utils.hasRecords(a_to_b.b_to_c)

and a_to_b was an empty foundset, Servoy would throw an error rather than return false. This was unfortunate because it meant you had to do this:

if (utils.hasRecords(a_to_b) && utils.hasRecords(a_to_b.b_to_c)) 

to be sure your code wouldn’t throw an error.

So Servoy kindly added this capability:

utils.hasRecords(source_record, 'a_to_b.b_to_c.c_to_d') 

which, rather than throwing an error, simply returns false if the chain of relations leads to an empty foundset at any point along the chain. I have made good use of this in my methods, but I don’t know how to use it in a calc, where I want the source record to be the record being calc’d? How do I specify the ‘record_currently_being_calculated’?

Thank you

Adrian,

The ‘this’ variable should point to the current record in a calculation, but that is not the case.

Please file a feature request with Servoy to allow accessing the current record as ‘this’.

In the mean time, use if (utils.hasRecords(a_to_b) && utils.hasRecords(a_to_b.b_to_c))

Rob