How to update the list of items from the response in some fields ?

1. I am calling an API on click of button. I am able to get response.  

Response Sample :  

{

Item1,

Item2,

Item3,

Item4

}

2.Now I want to put these values in some field (dropDownlist) where user can select it and use it. 

3.I had no idea how to put the items from response into dropdownlist or any other view filed. 

Please help me with  some suggestions and advice.

Version used : Sugar 10.3 (enterprise)

record.js

({
/*Disabling button ,condition based or dynamically on RecordView.
*
* custom/modules/Accounts/clients/base/views/record/reord.js
*/
extendsFrom:'RecordView',
initialize:function(options){
this._super('initialize',[options]);
//add listener for custom button
this.context.on('button:activate_button:click', this.activate_button, this);
},
activate_button:function(){
var self = this;
app.api.call('read', app.api.buildURL('Accounts/CustomerActivationAPI/' + this.model.get('id')), null,{
success:function(fdata)
{
console.log("Response", fdata);
},
error: function(error){
},
});
}
})

Parents
  • Just to be clear, you want to ADD these values that come back from the API to a drop-down.  So the API runs, the valuses get added to a dropdown and then the user can select ONE (or more I guess) of these values from the dropdown.

    Is that correct?

Reply
  • Just to be clear, you want to ADD these values that come back from the API to a drop-down.  So the API runs, the valuses get added to a dropdown and then the user can select ONE (or more I guess) of these values from the dropdown.

    Is that correct?

Children
  • Yes correct.

    Also changes should saved . I mean once values get added it should save in db. Once I do reload or navigate somewhere and come back to the same record, values should not get vanished. I dn't to click on 'Save'button as I have some logic hook on save.