Process definitions - Field evaluations for multi-select fields

I am using v7.8 Enterprise edition. 

So let's say I have a multi-select field with the following values:
- A

- B

- C

- D

- E

- F

- G

I want values A, B, and C to each trigger their own email notifications. So if the user selects A and C, two separate emails will go out: email A and email C. If the user selects any combination of the irrelevant fields - D, E, F, G - the record exits the program. However, as long as at least ONE of the relevant values (A, B, C) are selected, an email should go out. 

I can get the program to work if ONE relevant value is selected, but not multiple. I've tried a few different approaches, but it seems as though the operators are not really suited for multi-select lists. I have the option of "is" or "is not," which seems to indicate that I would need to provide every possible permutation - A OR (A AND B) OR (A AND B AND C), etc. 


I am using an inclusive divergent gateway to route the relevant values to the email notification steps, with one relevant value per offshoot of the gateway. I was hoping that the program would evaluate each field individually (e.g. as long as A is ONE of the values selected, the record routes through), but that doesn't seem to be the case (I guess because of the "Is" operator). Any suggestions?  Providing each possible permutation is not practical for my real-life application which has a ton more values than I listed above. 

Parents
  • If the field is a multi-enum you should have contains and not contains options.

    See: clients/base/filters/operators/operators.php

    $viewdefs['base']['filter']['operators'] = array(

        'multienum' => array(

            '$contains' => 'LBL_OPERATOR_CONTAINS',

            '$not_contains' => 'LBL_OPERATOR_NOT_CONTAINS',

        ),

        'enum' => array(

            '$in' => 'LBL_OPERATOR_CONTAINS',

            '$not_in' => 'LBL_OPERATOR_NOT_CONTAINS',

            '$empty' => 'LBL_OPERATOR_EMPTY',

            '$not_empty' => 'LBL_OPERATOR_NOT_EMPTY',

        ),

    I assume your "Field" dropdown is an enum so it's using the enum operators.

    By default something like what you have in the image would be trying to filter the "Field" not that fields' values

    I suppose you could try to force the "Field" to be a multienum or define your own field type with its own operators.

    It's not very clear to me how you are filtering that field's values as opposed to the filed names.

     

    If instead you were to filter things at code-level:

    multiselect values are encoded into a string where the values are comma separated and delimited with a ^

    For example: if you select A and C the value of the field in the database will be the string: 

    ^A^,^C^ or possibly ^C^,^A^ depending in which order you selected them.

    There are functions to decode and encode multienums

    See include/utils.php

    function unencodeMultienum($string)

    and

    function encodeMultienumValue($arr)

    unencodeMultienum('^A^,^C^') will give you an array with two values: A and C

     

    So you can unencode the value of the multienum and then check the array values for the relevant criteria.

     

    HTH,

    FrancescaS

Reply
  • If the field is a multi-enum you should have contains and not contains options.

    See: clients/base/filters/operators/operators.php

    $viewdefs['base']['filter']['operators'] = array(

        'multienum' => array(

            '$contains' => 'LBL_OPERATOR_CONTAINS',

            '$not_contains' => 'LBL_OPERATOR_NOT_CONTAINS',

        ),

        'enum' => array(

            '$in' => 'LBL_OPERATOR_CONTAINS',

            '$not_in' => 'LBL_OPERATOR_NOT_CONTAINS',

            '$empty' => 'LBL_OPERATOR_EMPTY',

            '$not_empty' => 'LBL_OPERATOR_NOT_EMPTY',

        ),

    I assume your "Field" dropdown is an enum so it's using the enum operators.

    By default something like what you have in the image would be trying to filter the "Field" not that fields' values

    I suppose you could try to force the "Field" to be a multienum or define your own field type with its own operators.

    It's not very clear to me how you are filtering that field's values as opposed to the filed names.

     

    If instead you were to filter things at code-level:

    multiselect values are encoded into a string where the values are comma separated and delimited with a ^

    For example: if you select A and C the value of the field in the database will be the string: 

    ^A^,^C^ or possibly ^C^,^A^ depending in which order you selected them.

    There are functions to decode and encode multienums

    See include/utils.php

    function unencodeMultienum($string)

    and

    function encodeMultienumValue($arr)

    unencodeMultienum('^A^,^C^') will give you an array with two values: A and C

     

    So you can unencode the value of the multienum and then check the array values for the relevant criteria.

     

    HTH,

    FrancescaS

Children