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. 

  • 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

  • I came here with a similar question to the OP. I've got a multiselect question and like to kick off a process when one of the items is selected, but the process will only kick off it it's the ONLY one selected. There is no "includes" option in the module field evaluation, only "is" or "is not". Unfortunately, I don't know enough about coding within Sugar to go down that route at this time.

  • I am looking for exactly the same functionality within one of my own definitions. As Scott mentions above, it will only start if I have only one option in each section of the divergent gateway. I can workaround this, but it will make my workflow much less simple to manage going forward. Does anyone know if an enhancement has been logged for this? If so, its getting a +1 from me.

  • Aaron, we utilize the following workaround:

    - Create a hidden checkbox field for each multi-select value that needs to trigger a workflow

    - The checkbox contains the following calculated value formula, which toggles the checkbox to "true" if the relevant multi-select value is added: ifElse(contains($mutli_field_c,"Multi Value"),true,false)

    - A true value in the check box is then used to trigger the start event in the workflow

    Hope that helps.