Reports and multi select fields

Hello,

I have a multi select field named company title. In the company title field, I have Director, Company Rep, Admin. This is a multi select field. Each contact might be the Director and the Company Rep.

When it comes to reporting, you can select either equals or not equals. This would work with a normal select field, but not with multi select fields. If I want a report show all my Company Reps, it only shows the contacts that have only Company Rep selected. If I have a contact that is both a Director and a Company Rep, that contact is not included in my report.

If you can change the pull down for multi select fields to equal, contains, and not equipment, that would be very helpful.

Hi there,

Thank you for your suggestion.

Regards,

Will.

I created a workaround for this problem:

  1. Correct a bug in the function unencodeMultienum (which is located in: include/utils.php)
    Since I am not sure if this function is used elsewhere successfully I created a new one and included it just before the class definition in modules/AOR_Reports/AOR_Report.php

This is the new correct function code:

function MyOwn_unencodeMultienum($string) {
	if (is_array($string))
	{
	   return $string;
	}
	if (substr($string, 0 ,1) == "^" && substr($string, -1) == "^") {
          $string = substr($string, 1);
          $string = substr($string, 0, -1);
	}

	return explode('^,^', $string);
}

(The bug is due to the fact that the original funtion trims two characters on the right hand side of the string instead of one)
For better readability I also separated the trimming on the left and the right into two statements.

  1. Call MyOwn_unencodeMultienum instead of unencodeMultienum
    in modules/AOR_Reports/AOR_Report.php
    substitute
    unencodeMultienum

with MyOwn_unencodeMultienum
(there is only one occurrence in a line that looks like:

                            $multi_values = MyOwn_unencodeMultienum($condition->value);
  1. Change the operator of the ‘Multi’ statement from ‘=’ to ‘REGEXP’
    To do so you have to change the following code five lines below the call (now) to MyOwn_unencodeMultienum:
                                   $value .= $field.' '.$app_list_strings['aor_sql_operator_list'][$condition->operator]." '".$multi_value."'";

To:

                                      if($condition->operator == 'Equal_To')
                                        $value .= $field.' '.'REGEXP'." '".$multi_value."'";
                                      else
                                        $value .= $field.' '.'NOT REGEXP'." '".$multi_value."'";

Now if you select one or more options in the multiselect field the report will return all those records with at least one of the options.
This is because they are grouped with OR
The code is written in such way that, if you want to group them with AND you have to chose Not Equal (I don’t know why they did it this way)

By the way there is a bug because if you chose “Not Equal To” it is saved as “Equal To”!! Thanks to this bug you can select those who have two or more values!

Of course you will continue to see in the dropdown “Not Equal To” and “Equal To” but at least you get the functionality!

3 Likes

Thanks bro… This bug still in 7.5 version…

Have you tested the latest release of 7.5? Is it still an issue?

If so, can you log it on the SuiteCRM GitHub Repository?

Thanks,

Will.

I had the same problem and this workaround solve my problem. There are a lot of issues related with this problem. Does anyone already share this workaround on github? Could be helpful to solve the problem.

Hello,
we have the same problem here. We are not able to select the option “contains” in a multi select field in a report. The search condition is very complicated to use, when we want to search different values in this field.

It is possible to fix this problem? Exists a workarround without any code changes in the system?

Best regards,
Fabian

This makes reporting on multi select fields virtually impossible.

There seems to be multiple mentions of this in git hub with not resolve, is anyone aware of an update yet?

Many thanks

Luke