Hey,
When accessing relations, you should be careful because in the web client, it will not work when there are no records in the relation.
E.g.
if(relation_name.field_name != null)
will give an error.
Mind you this piece of code will work just fine in the Smart Client!!!
So, prior to any checking, the existence of records in the relation has to be checked with the databaseManager.hasRecords()
function. Which returns a true if there are records in the relation.
E.g.
if((databaseManager.hasRecords(relation_name))&&(relation_name.field_name != null))
Regards
Hareendra
I am surprised to hear that you say that
relation.fieldName
does not give an error in the Smart Client if the relation has no records. From my experience it is always necessary to check for the existence of related records before accessing a field. I can’t imagine that in this area there is any difference between Smart and Web Client.
thats correctly for scripting there is no difference like that for the web or smart client
the relation should be checked for both
I checked my performance statistics to see how often a query is being done.
As far as I could see the following code will do 2 queries:
if((databaseManager.hasRecords(relation_name))&&(relation_name.field_name != null))
One for the hasRecords() method and also one to retrieve the field.
Am I right about that?
no that shouldnt be 2 queries, it should be 1 just to load the first bunch of rows for the related foundset.