Getting all related records from the current record

Hi,

I’d like to get all the records related to the current record selected in the current foundset, BUT WITHOUT A VALUELIST.

So I’d like the value list functionality without having to decalre the value list, because I want to get the related values, even if no valuelist are defined.

And I want to get the related values of the current record without affecting my current foundset

I’ve found this :

convertFoundSet
Converts a foundset based on a one-to-many relation; returns a foundset of all related records based on a specified relation.

But it seems to affect my foundset and it seems to return all the related values of all the records of my foundset.

I only want the related values of the current record I’m on.
Thanks

And what do you want to do with those “values” (actually you get records)? You can do something like

// Get hold of the record you are on
var vMyRecord = foundset.getRecord(foundset.getSelectedIndex())
if (utils.hasRecords(vMyRecord.relation)) {
   for (var i = 1; i <= vMyRecord.relation.getSize() ; i++) {
   // Get a related record
   var vRelatedRecord = vMyRecord.relation.getRecord(i)
   // Get a related "value"
   var vMyValue = vRelatedRecord.field
}
}

Hope this helps.

I’m not sure if I understand your question correctly, what do you exactly mean when you say “value list functionality”?

To address a related foundset you can just use the relation name. Check the “relations”-node under your form in the editor.

Also note that it is possible to base a value list on a relation and only show the related values of the selected record.

Thanks patrick, it helped