AnsweredAssumed Answered

Trouble fetching related in record.js

Question asked by Shad Mickelberry on May 25, 2017
Latest reply on May 26, 2017 by Shad Mickelberry

Hello I am having a bit of trouble with getting data from a relate field in a custom record.js file. Below I have the code sample. I've been trying different data:sync:complete and render triggers. The function is called but I can't get the data out. 

this.collection.on('data:sync:complete', this.getRelatedFields, this);
this.model.on('data:sync:complete', this.getRelatedFields, this);
getRelatedFields: function () {
    var self = this;
    var closing_notary_id = self.model.get('apps_notaries_id1_c');
    debugger;
    if (!_.isEmpty(closing_notary_id)) {
        var closing_notary = app.data.createBean('apps_Notaries',{id: closing_notary_id});
        closing_notary.fetch();
        var phone = closing_notary.get('phone_work');
        self.model.set('closing_notary_phone_c',phone);

    }
},

 

When I use the Chrome console and call at the break point I get. But it works if I wait until the page has finished loading.@

stash.min.js:2 Uncaught TypeError: Cannot read property 'apply' of undefined 

 

I could use an after_retrieve logic hook instead but was hoping to use sidecar.

 

Any assistance would be appreciated.

Outcomes