AnsweredAssumed Answered

Hide related field depending on the value of a Dropdown List(or other logic)?

Question asked by Arpad Szabo on Dec 15, 2016
Latest reply on Jul 3, 2017 by Arpad Szabo

Hello I wanted to hide two fields depending on a dropdown value:


System: Sugar Enterprise 7.8



Module where I want to hide: moduleA

On record/create view there is a dropdown: docType (values: typeB, typeC, both, none)

There is two related modules: moduleB, moduleC


Logic (trying to write as a pseudo code):


If the docType=typeB

   hide moduleC related field;


Else if the docType=typeC

   hide module B related field;


Else if the docType=none

   hide both related field;


Else if the docType=both

   do nothing, dont hide the related field;


There is a solution trough the create.js and record.js but a little bit old, and not detailed: How to hide a field in preview? 


Tried something like that but not works.




({     extendsFrom: 'RecordView',      initialize: function (options) {
     this._super('initialize', [options]);this.model.on('hide:related',_showHideFields);     },
     _showHideFields:function(model, collection, fetch) {
          var docType = this.model.get('docType_c');// fetches  docType dropdown value
          if(doc_type === "typeB")
          else if(doc_type === "typeC")


There is missing something?

The code just not works.


Thank You for Your suggestions!