Announcement

Collapse
No announcement yet.

Adding to multi-Enum

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

  • Adding to multi-Enum

    Hi I'm trying to make to control several boolean fields with a multi-enum, to do that I made a process that on a change on any boolean, it'll make the whole multi-enum array from scratch, it being the most efficient way of doing it is not the point, the issue I have is that I get successfully an array with the size desirable and with each position containing the correct value, but I can't make it show as a multi-enum. Can anyone help me with this?

    Thanks, I'm leaving here my code.

    $array = list();
    ifThen(tcStudent == true, $array = array\push($array, 'Student'));
    ifThen(tcAlumni == true, $array = array\push($array, 'Alumni'));
    ifThen(tcParticipant == true, $array = array\push($array, 'Participant'));
    ifThen(tcApplicant == true, $array = array\push($array, 'Applicant'));
    ifThen(tcResearcher == true, $array = array\push($array, 'Researcher'));
    ifThen(tcProfessor == true, $array = array\push($array, 'Professor'));
    ifThen(tcPress == true, $array = array\push($array, 'Press'));
    ifThen(tcAffiliatedProfessor == true, $array = array\push($array, 'Affiliated Professor'));
    ifThen(tcScientificCouncil == true, $array = array\push($array, 'Scientific Council'));
    ifThen(tcBoardOfTrustees == true, $array = array\push($array, 'Board of Trustees'));
    ifThen(tcInstitutional == true, $array = array\push($array, 'Institutional'));
    ifThen(tcMarketing == true, $array = array\push($array, 'Marketing'));
    ifThen(tcSalesProspect == true, $array = array\push($array, 'Sales'));
    ifThen(tcRecruiter == true, $array = array\push($array, 'Recruiter'));
    ifThen(summerForumOrganizer == true, $array = array\push($array, 'Summer Forum Organizer'));
    ifThen(tcStaff == true, $array = array\push($array, 'Staff'));

    //record\update('Contact', id, 'tcSummary',$array ); // tried both methods none work as desired.
    tcSummary = $array;

    description = array\length(tcSummary); //for control purposes



    Thanks everyone!​

  • #2
    Hi,
    You can use Dynamic Logic

    Comment


    • #3
      Hello,

      In order to change the multi-enum options immediately you will need to work with the front end.

      Formula is essentially a user friendly way to write beforeSave PHP hooks, so it only takes place AFTER you save an entity.

      Dynamic Logic, as correctly suggested by Kharg, does work in real time, but it is not very flexible as it requires you to define all possibilities at the field definition time and saves them in metadata, so any change in the logic or parameter values will require an Admin change to the field definition. I you are OK with this, it is perhaps the easiest solution.

      Another option would be to use the Dynamic Handler facility https://docs.espocrm.com/development/dynamic-handler/ which requires a little bit of javascript coding but it is a lot more powerful in my opinion.

      Finally, if you don't mind getting your hands dirty with actual javascript coding, Multi-enum and Enum options are controlled by the method "setupOptions" in the field view class.

      Here's a post that describes how to manipulate multi-enum options in real time, perhaps that can help you accomplish your goals

      The idea of this thread is to create a "road map/guide" to help developers find where GUI sections or elements are defined within Espo code so customization projects can be implemented without having to spend a lot of time "finding your way around" the code (like many of us have done) whenever possible.


      Good Luck !
      Last edited by telecastg; 02-19-2023, 10:16 PM.

      Comment

      Working...
      X