I am new to sugarCRM. Recently I have searched for the same solution and google drop me here. I tried the above solutions but they are working for only dropdown field. Since, sugar logic is not working for multiselect field dependency. Multiselect field dependency keeps values as Objects. SO, by converting it into array and iterating the array we can find whether the multiselect field contains our required value or not.
I know this this is very late but this will be helpful for the future readers like me.
//solutions_c is Multiselect field //revenue_c is Textfield initialize: function(options) { this.plugins = _.union(this.plugins || [], ['HistoricalSummary']); this._super('initialize', [options]); //declare onChange this.model.on("change:solutions_c", this.SolutionsOnChange, this); }, SolutionsOnChange: function(){ var solutionsField = this.model.get('solutions_c').toString(); var flag = 0; //set flag as 0 //exploid by (,) var solutionsArray = solutionsField.split(","); for(var i = 0; i < solutionsArray.length; i++ ){ if(solutionsArray[i] == "Electronics"){ flag = 1; //set flag as 1 } } if(flag == 1){ $('[data-name="revenue_c"]').css('visibility', 'visible'); } else{ $('[data-name="revenue_c"]').css('visibility', 'hidden'); } },
Thank you,
I am new to sugarCRM. Recently I have searched for the same solution and google drop me here. I tried the above solutions but they are working for only dropdown field. Since, sugar logic is not working for multiselect field dependency. Multiselect field dependency keeps values as Objects. SO, by converting it into array and iterating the array we can find whether the multiselect field contains our required value or not.
I know this this is very late but this will be helpful for the future readers like me.
//solutions_c is Multiselect field //revenue_c is Textfield initialize: function(options) { this.plugins = _.union(this.plugins || [], ['HistoricalSummary']); this._super('initialize', [options]); //declare onChange this.model.on("change:solutions_c", this.SolutionsOnChange, this); }, SolutionsOnChange: function(){ var solutionsField = this.model.get('solutions_c').toString(); var flag = 0; //set flag as 0 //exploid by (,) var solutionsArray = solutionsField.split(","); for(var i = 0; i < solutionsArray.length; i++ ){ if(solutionsArray[i] == "Electronics"){ flag = 1; //set flag as 1 } } if(flag == 1){ $('[data-name="revenue_c"]').css('visibility', 'visible'); } else{ $('[data-name="revenue_c"]').css('visibility', 'hidden'); } },
Thank you,