AnsweredAssumed Answered

How can I do a synchronous api call in Sugar 7?

Question asked by Mike Solomon on Jul 3, 2014
Latest reply on Jul 3, 2014 by Mike Solomon
I'm doing a custom api call in my accounts record.js

I need to get the result of the api call before I do anything else but the call appears to be asynchronous

Is there a way of changing this?

My code in record.js is

         var type = 'noaction';
         
          var AcctID = this.model.get('id');
           app.api.call('GET', app.api.buildURL('Accounts/' + AcctID + '/set_home'), null, {
            success: function(data) {
            console.debug('data' + data)
            type = data;

            },
            error: function(error) {
            console.debug(error)
            }
});
         
           console.debug('type' + type)
If I look at my console the 'type' + type comes before the 'data' + data


Outcomes