AnsweredAssumed Answered

SugarCRM 7 : set dropdown value

Question asked by Gaelle Fernandez on Feb 17, 2016

Hello everyone !

 

I've came accross a little bug i can't explain and i need your help :

I have a field in Case modules named "priorite_c". This field is a dropdown value which can only have "Haute" or "Normal" as choices.

In this Case module, i have another field called "categorie_demande_c", which is another dropdown with several choices

 

I want to change priorite_c value when categorie_demande_c changes, according to a certain rule : If categorie_demande_c = "reclamations", then priorite_c has to change to "Haute".

I've wrote in record.js the following code :

 

({

    extendsFrom: 'RecordView',

    initialize: function(options) {

        this._super('initialize', [options]);

        this.on("render", this.displayPriority, this);

       

        this.model.on("change:categorie_demande_c",this.displayPriority, this);

        this.model.on("change:sous_categorie_demande_c",this.displayPriority, this);

       

  },

    displayPriority:function(){

        if (this.model.get('categorie_demande_c') === "reclamations"){

            this.model.set('priorite_c',"haute");

        }else{

            this.model.set('priorite_c',"normale");

        }

    },

       

})

 

And i don't understand, because the javascript is not taken in account, and of course, not saved (even if the user hit the "Save" button)

 

Could you please help me on this?

 

Thanks a lot.

Outcomes