Announcement

Collapse
No announcement yet.

Two Multi Enum Field with Conditional options

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Two Multi Enum Field with Conditional options

    Hi,

    I have faced an issue with Two multi enum fields with conditional options. Please refer attached screenshots so you will have better understand what i was going to do. Simply I want that is,

    From continent field if I chose two continent from trade lane field it will only has to be show trade lanes from each continent.

    What I need to be done
    Ex:
    Continent = Asia, Oceania
    Trade Lane = India, Pakistan, Australia, Papua New Guinea


    But i'm getting only data from single continent according to Conditional options order

    Conditional Order Asia,Africa,Oceania

    Data i'm getting is with the current

    Continent = Asia, Oceania
    Trade Lane = India, Pakistan

    Continent = Asia, Africa
    Trade Lane = India, Pakistan

    Continent = Africa, Oceania
    Trade Lane = Nigeria, Ethiopia
    Attached Files
    Cheers!
    Nishan.

  • #2
    I never knew you can do Conditional Formatting like that. Will need to play with it, but from a brief look at your Conditioning it seem like you have 3 separates condition?

    I think for this to work you need to find out how to use the "OR" and "IF" statement.

    Will need time to explore this, I haven't use this so can't give any advice.

    Comment


    • espcrm
      espcrm commented
      Editing a comment
      Wow I finally manage to get around to playing with this feature today. Did not even know it existed! That + button at the very button is rather hidden, all I see was the 3 first button with 3 conditions but there is this "4th" condition available.

      I played with it using just enum (single) and it work great (after refreshing browser to make sure). I only start using it for the Account (Industry > Type) at this stage. Will begin to explore updating for other field and eventually try Multi-Enum to see if I can figure out how to make it work for you.

    • Nishan Perera
      Nishan Perera commented
      Editing a comment
      Hi @espcrm,

      have you tried that with two multi-enum ?

  • #3
    Maximus Can I have your input for above request with two Multi-Enum ? Im still stuck with that.
    Cheers!
    Nishan.

    Comment


    • #4
      Nishan Perera Hi,

      Since I was pinged I decide to give it a couple test on how to make it work. Can't seem to find any that make it simple though. From my method you will need to create option for each type of Option.

      For example:
      Continent1 - Trade1
      Continent2 - Trade2
      Continent3 - Trade3
      Continent4 - Trade4

      Your conditional option will need to look like this, which is very tiring once you get lots of option.

      Field=Continent1
      AND
      Field=Continent2
      Trade1, Trade2
      ---

      Field=Continent1
      Trade1
      ---
      Field=Continent2
      Trade2
      --

      Field=Continent1
      AND
      Field=Continent3
      Trade1, Trade3
      --

      Field=Continent1
      AND
      Field=Continent4
      Trade1, Trade4
      ---
      etc, etc until you have all "filter" option considered for.

      But if you allow for 3 Continent to be selected, that even worse. There may be a better way to do it, but I don't think it is possible with the current default coding.
      Last edited by espcrm; 06-25-2020, 06:22 AM.

      Comment


      • Nishan Perera
        Nishan Perera commented
        Editing a comment
        espcrm, I actually tried that way. But will try again this. there should be a easy way. will see.

    • #5
      Hi Nishan Perera,
      espcrm is right. You need to define a logic for all possible options. Please investigate my screenshot to see how it should be configured to make what you want. Note that condition should be set in the same order as it shown in my example (from big to small).
      Attached Files

      Comment


      • #6
        Maximus written it more beautifully. That the only way I could think of with the current available GUI.

        I had tried a couple of AND, OR and NOT contain but all fail to work properly. Only the above setup work well but it get messy once you have even more messy once you add all 7 Continent and Trade Route.
        Last edited by espcrm; 06-30-2020, 08:00 AM.

        Comment


        • #7
          This tutorial shows how you can use the selections of one multilink field to control the options for a second multilink field. https://forum.espocrm.com/forum/deve...-multiple-link

          If you define "continent" as an entity and "tradeLane" as another entity, you could accomplish what you are trying to do this way and you won't be forced to change the multienum field options manually each time that a new trade lane might be added or deleted and do some very long manual definitions.
          Last edited by telecastg; 07-22-2020, 05:42 PM.

          Comment


          • #8
            Hi folks,
            telecastg made the amazing tutorial of how to affect link fields. It pushes me toward my old desire to create a tutorial of how to create the described in this topic dynamic logic on the code layer. As you may noticed the UI dynamic logic is a pretty complicated to managing, fixing errors and rewriting. Making the dynamic logic with coding needs some code skills but it allows you to fix and make changes very easily. So let's start.
            1. Create or open the file /custom/Espo/Custom/Resources/metadata/clientDefs/Your-entity.json and add this link:
            Code:
            {
            [COLOR=#c0392b]"dynamicHandler": "custom:basic-dynamic-handler"[/COLOR]
            }
            2. Create the file /client/custom/src/basic-dynamic-handler.js with this logic:
            Code:
            define('custom:basic-dynamic-handler', ['dynamic-handler'], function (Dep) {
            
                return Dep.extend({
            
                    init: function () {
                        this.controlFields();
            
                        this.recordView.listenTo(
                            this.model, 'change:continent', this.controlFields.bind(this),
                        );
                    },
            
                    controlFields: function () {
                        var continent = this.recordView.model.get('continent');
            
                        if (continent.includes('Africa') && continent.includes('Asia') && continent.includes('Oceania')) {
                            this.recordView.setFieldOptionList('tradeLane', [
                                'India',
                                'Pakistan',
                                'Nigeria',
                                'Ethiopia',
                                'Australia',
                                'Papua New Guinea'
                            ]);
                        } else if (continent.includes('Africa') && continent.includes('Asia')) {
                            this.recordView.setFieldOptionList('tradeLane', [
                                'India',
                                'Pakistan',
                                'Nigeria',
                                'Ethiopia'
                            ]);
                        } else if (continent.includes('Africa') && continent.includes('Oceania')) {
                            this.recordView.setFieldOptionList('tradeLane', [
                                'Nigeria',
                                'Ethiopia',
                                'Australia',
                                'Papua New Guinea'
                            ]);
                        } else if (continent.includes('Asia') && continent.includes('Oceania')) {
                            this.recordView.setFieldOptionList('tradeLane', [
                                'India',
                                'Pakistan',
                                'Australia',
                                'Papua New Guinea'
                            ]);
                        } else if (continent.includes('Africa')) {
                            this.recordView.setFieldOptionList('tradeLane', [
                                'Nigeria',
                                'Ethiopia'
                            ]);
                        } else if (continent.includes('Asia')) {
                            this.recordView.setFieldOptionList('tradeLane', [
                                'India',
                                'Pakistan'
                            ]);
                        } else if (continent.includes('Oceania')) {
                            this.recordView.setFieldOptionList('tradeLane', [
                                'Australia',
                                'Papua New Guinea'
                            ]);
                        }
                    }
                });
            });
            3. Administration -> Clear Cache
            4. Refresh a webpage

            Documentation is here https://docs.espocrm.com/development/dynamic-handler/.

            Comment


            • #9
              actually this is a highly impressive guideline. Thanks Maximus & telecastg great tutorial.!
              Cheers!
              Nishan.

              Comment

              Working...
              X