How to fetch related records in JavaScript

Hi All,

I trying to fetch related records using the following methods,but 

  

var parentBean = app.data.createBean('parentmodule', { id: parentId });
var relatedRecords = app.data.createRelatedCollection(parentBean, 'relatedmodule');

  

relatedRecords.fetch();

But the results not displaying the related records.

Please help me to get solution for this

  • You must do something like that:

      

    relatedCollection = app.data.createRelatedCollection(parentBean, 'relatedmodule');
    relatedCollection.fetch({
     relate: true,
     success: function(data) {
     self.evaluateResult(data);
     if (!self.disposed) {
     // do something
     }
     },
     error: _.bind(function() {
     this.displayNoData(true);
     }, this),
    complete: options ? options.complete : null,
     limit: -1,
     fields: this.getFieldNames()
    });

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada