Field dependancy : display a textfield dependant from a custom multi-enum

Hello there !

i'm building a new project under Sugar Pro 7.5.2 and i'm meeting some difficulties : 

What i have and what i would like :

I have created a muliple choices dropdown, and a textfield.
I would like to display the textfield only if the user choses a specific value of my multi-enum dropdown.

So normally i would do that through studio, with the dependancy formula.


What i tried and what failed :

But there is a problem : my multi choice dpdwn is not showing under the Fields column in the formula editor. And even if i try to add it manually in my formula, i have an error of "field unrecognized".

So, how can i display a field on a Multi select field dependancy ?

I did not find any tips or tricks in my Community search, i even found martin peet being unanswered :
Using a Multi select box as dependancey criteria

it's been one year !

Please, tell me if i'll have to do that by code, and how.

Have a nice day ! :)
  • I would do like this: in your editviewdefs file, include in you field the follow: 
    'displayParams' => 
    array (  
          'field' => 
          array (
             'onchange' => 'someFunction()',
          ),

    In this function you may programming via java script the code to handle the hide/display logic.
  • Hi,

    In your record view controller, you can handle this scenario using the following code:

        extendsFrom: 'RecordView',
        initialize: function(options) {
            this.plugins = _.union(this.plugins || [], ['HistoricalSummary']);
            this._super('initialize', [options]);
      this.model.on("change:is_show_c",this.CustomOnChange, this);
        },
    CustomOnChange: function(){
      var is_show_c1=this.model.get('is_show_c');
      if (is_show_c1 == "No")
        $('[data-name="testfield_c"]').hide();
      else
        $('[data-name="testfield_c"]').show();
       },


    // is_show_c is the multi select field
    // testfield_c is the text field 
    Rolustech: SugarCRM Engineering
    Website: www.rolustech.com
    Ph (US): +1 - 310 - 492 - 5564
    Ph (UK): +44 - 207 - 9938 - 524
    Email: info@rolustech.com
    Skype: rolustech
  • Hi Rafael,
    Thank you for your answer, but this little code only works for Sugar 6, not Sugar 7 (we do not have ediviewdefs anymore in 7)
    Have a nice day !
  • Thanks a lot, i'm a little rusted in Sugar 7, so thanks a lot for that ! i'll try and come back to you :)
  • It was a pleasure. :).

    Rolustech: SugarCRM Engineering
    Website: www.rolustech.com
    Ph (US): +1 - 310 - 492 - 5564
    Ph (UK): +44 - 207 - 9938 - 524
    Email: info@rolustech.com
    Skype: rolustech
  • Well, @Rolustech, i think in fact your solution works for simple dropdown, but not for multi select dropdown ...

    Or maybe i'm wrong ? here is my code, (with scoring_2_roues_c being the dropdown and detail_scoring_2_roues_c being my text field to hide).
    ({    extendsFrom: 'RecordView',
        initialize: function(options) {
            /*this.plugins = _.union(this.plugins || [], ['HistoricalSummary']);
            this._super('initialize', [options]);*/
      this.model.on("change:scoring_2_roues_c",this.CustomOnChange, this);
        },
    CustomOnChange: function(){
       var scorValue=this.model.get('scoring_2_roues_c');
       alert(scorValue);
       if (scorValue == "sautr")
        $('[data-name="detail_scoring_2_roues_c"]').hide();
       else
        $('[data-name="detail_scoring_2_roues_c"]').show();
       },
    })

    And i put it in custom/modules/Leads/clients/views/record/record.js
  • We have tested this code snippet with multi select dropdown, please remove the block comment from your code and the correct path should be custom/modules/Leads/clients/base/views/record/record.js.

    Rolustech: SugarCRM Engineering
    Website: www.rolustech.com
    Ph (US): +1 - 310 - 492 - 5564
    Ph (UK): +44 - 207 - 9938 - 524
    Email: info@rolustech.com
    Skype: rolustech
  • I've moved my record.js file, and removed the comment block, but there is not much improvement.
    it seems that Sugar does not even consider my file.
    i've added a little 
    console.log("we are overriding record"); into the initialize function, but even that is not showing.. 
    If you have any help, i'll be glad to hear it :)
  • Did you run repair n rebuild afterwards?

    Rolustech: SugarCRM Engineering
    Website: www.rolustech.com
    Ph (US): +1 - 310 - 492 - 5564
    Ph (UK): +44 - 207 - 9938 - 524
    Email: info@rolustech.com
    Skype: rolustech
  • This is very nice to discuss and share very useful source of information it will really help people thanks ...
1 2 3