AnsweredAssumed Answered

How do you fill a dropdown with json in 7?

Question asked by Gaelle Fernandez on Aug 5, 2014
Latest reply on Sep 7, 2016 by sidhu sidhu
Hello everybody!

I am currently working on a difficult problem..

What i want to achieve :
In a custom module, i would like to fill a custom dropdown (which was created through studio) with the contacts which are related to an Accounts selected in related field.

because the solution of eggsurplus won't work in 7.2.0 (We can't pass parameters to the custom function, so i will not be able to pass account_id to make my query work), i figured that i could call a little ajax code when account field does change.

So, i did the following :
in custom/modules/<myModule>/clients/base/views/record/record.js , i've extended the view :

({extendsFrom: 'RecordView',

initialize: function(options) {
this._super('initialize', [options]);
this.model.on("change:societe_marraine_c",this.getContactsSociety, this);

var societyid = this.model.get('account_id_c');
        type: 'POST',
        url: 'http://&lt;mySugar&gt;/index.php?entryPoint=retrieveContact',
        data: {societyid : societyid},
        success: function(data) {
          error: function(){

As you can see, my record js calls a function when societe_marraine_c changes. This function then calls a little ajax, which leads to a custom entryPoint. This entryPoint get the societyid and makes a query to the sql. it then returns data in json , which looks like this :

   "name":"Julien Clerc"
    "name":"Georges Brassens"

I would now like to populate my field contact_society_c (which already has a default list), with these new values.

How to do that on my record.js? i've searched for all this afternoon, and can't figure out how to do this.

Backbonejs is really obscur for me, so i'm begging you for some help.

Thanks a lot.