Sorting related field using Method

Hi,

I have an invoice list where I show the contact & company names who are linked to the invoice.

I allow the user to sort the records by clicking on the column header (using labels). The name of the label is set exactly same as the field name.

The following method sorts the records with the name of the button triggered which is exactly the field name

frmObj1 = globals.nav_commonScripts('getFrmObj');
var btnName = application.getMethodTriggerElementName();
 frmObj1.controller.sort(btnName);

I have no problem in sorting the normal fields. But I don’t know how to sort by related fields like contact & company name which is actually displayed using relation. I cannot set the label name similar to like “frmInvoiceList.invoice_to_contact.first_name” and hence I donno how to sort this. Is there a direct way of doing this? I don’t want to provide to the user with the sort dialog.

Thanks
Ahmad

don’t do it in a generic way.
Just program for those 2 fields the code exactly out
(so hard in the code:

.sort(‘relation.xxxx’)

that looks to me like the best way