Announcement

Collapse
No announcement yet.

getRepository -> find using whereClause to filter multiEnum fields

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

  • getRepository -> find using whereClause to filter multiEnum fields

    Hi there

    I have a custom entity with a multiEnum field called "statut"
    i try to write a custom entrypoint to build a custom dashboard, adding some stuff to filter my dashboard

    I have tried many differents synthax but i don't manage to filter my data regarding "multiEnum" fields value.

    Here is my php code
    PHP Code:
    $whereClause = array();
    $whereClause['statut=*'] = 'Prospect';
    $order_by "name";

    $searchParams = array(
    'whereClause' => $whereClause,
    'orderBy' => $order_by
    );

    $data $this->getEntityManager()->getRepository('DossierMDB')->find($searchParams); 
    i tried many synthax about => $whereClause['statut=*'] = 'Prospect';
    $whereClause['statut'] = 'Prospect';

    or

    $whereClause[] = array('statut' => 'Prospect');

    or

    $whereClause[] = array('statut' => array('Prospect'));

    but didn't manage to get any filtered results

    any idea?

    Thanks for your support !

    I didn't find any documentation about the synthax available for the "keys" of that whereClause array :-(
    https://github.com/espocrm/documenta...lopment/orm.md

  • #2
    After digging... i found this synthax that seems to work

    PHP Code:
    $whereClause[] = array('statut*' => '%' $mdb_statut[$_GET['statut_index']] . '%'); 
    am i right?

    Comment


    • #3
      Try to wrap Prospect in %

      Comment


      • #4
        Yep, thanks !
        i found all the different synthax in application/Espo/Core/SelectManagers/Base.php
        switch case :-)

        Thanks !

        Comment


        • #5
          More info added at https://github.com/espocrm/documenta...lopment/orm.md

          Comment


          • #6
            yuri
            Thanks that's perfect !!

            Another point: how do you escape value of a multiEnum list ? I have "'" and "/" in some values and it doesn't seem to work.
            I tried to addslashes / stripslashes but not working

            Ex: my field called "Stage" has these values => "A / B", "B'C", "C-D"

            Thanks for your support!

            Last edited by wtconseil; 02-12-2018, 02:22 PM.

            Comment


            • #7
              tanya maybe an idea? thx

              Comment


              • #8
                You have to escape \
                $whereClause['tesst*'] = "%A \\\\/ B%";

                Comment


                • #9
                  Thanks !
                  $data = str_replace("/", "\\\\/", $data)

                  Comment

                  Working...
                  X