Hi all,
Im having a problem returning a record back from our custom countries module when we change a dropdown field in our accounts record.
Ive added a function to records.js to handle detecting the change and passing the value to a function. I am then trying to use the app.api to make a request to find the record and return the data
records.js
extendsFrom: 'RecordView',
initialize: function (options) {
this._super('initialize', [options]);
this.model.on('change:billing_address_country', this._setMarketingRegion, this);
},
_setMarketingRegion: function(model) {
var country = this.model.get('billing_address_country'),
url = app.api.buildURL("Countries", null, null, {
"filter" : [{
"name" : country
}]
});
if (country) {
app.api.call('GET', url, null, {
success : _.bind(function (response) {
console.log(response);
}, this),
error : _.bind(function (error) {
console.log("Error", error)
}, this),
});
}
},
this is successfully capturing the value from biilling_address_country but when I try to generate the url and return the result I get an empty array
I can return the url and paste this into postman which works correctly and returns the expected result. However when i try to use this in app.api.call() I don't get any response.
the url generated is Countries?filter%5B0%5D%5Bname%5D=United%20Kingdom and this works in postman
Have also tried the following