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
  • Hi Gautam,

    You have to set the values to model in the code and save the model.

    Please try to add something like this inside the success function.

    success:function(fdata)
    {
    console.log("Response", fdata);

    self.model.set('fieldname1', Item1);
    self.model.set('fieldname2', Item2);
    self.model.save();

    },

    where Item1 and Item2 you will be getting from your response and fieldname1,fieldname2 are the field names in your module.

    Hope this helps.

    Thank you

    Poojitha Katram

    Senior Solution Engineer,

    www.bhea.com

Reply
  • Hi Gautam,

    You have to set the values to model in the code and save the model.

    Please try to add something like this inside the success function.

    success:function(fdata)
    {
    console.log("Response", fdata);

    self.model.set('fieldname1', Item1);
    self.model.set('fieldname2', Item2);
    self.model.save();

    },

    where Item1 and Item2 you will be getting from your response and fieldname1,fieldname2 are the field names in your module.

    Hope this helps.

    Thank you

    Poojitha Katram

    Senior Solution Engineer,

    www.bhea.com

Children
No Data