Running SuiteCRM 7.8.31 and I would like to generate reports - to later be used as target lists for email marketing campaigns - where one of the criteria fields needs to match multiple values. An example would be to select targets in several different cities for the report (and subsequent marketing campaign.)
I see that a field used for criteria can use ‘Equal to, Not equal to, Contains, Begins with and Ends with’ but I am in need of a more flexible solution by being able to express the desired matches by writing a regular expression. An example could be that selection would be based on eg ‘(New York|Washington|Baltimore)’ etc.
Surely someone must have run into this problem before and may have a work-around or solution?
I looked at the code of AOR_Report.php and the function build_report_query_where and the section ‘handle like conditions’. This section has a switch statement using $condition->operator where the cases are ‘Contains’, ‘Starts With’ and ‘Ends With’. It would seem to me that it might be possible to add regular expression capabilities to ‘Contains’ - provided that the database to which the query will be sent can handle a regular expression. A quick check on the MariaDB website suggests that version 10.0.5 and later has a REGEXP operator.
After some experimentation I simply replaced $aor_sql_operator_list[‘Contains’] = ‘LIKE’ with $aor_sql_operator_list[‘Contains’] = ‘REGEXP’ which in the limited testing I have done so far seems to work as expected.
However, I found that the input field in the report where you can enter condition is limited to exactly 100 characters and for some complex patterns, eg listing a number of cities, more characters would be needed. Is it easy to increase this number?
I don’t know about the field width change, but maybe you can search Github, there was a PR a couple of years ago, changing name length, that might help. It might be as simple as a vardefs change, and then a QR&R, running the suggested queries there. But be careful, try it in a test system first.
But that generated problems, made a few indexes in the database become excessively long. I don’t think it will happen with Workflow conditions, but caution is advised…
I agree that since this is a workflow item rather than a database change it ought to be safe to increase the field length to more than 100 characters. However, editing vardefs.php in AOR_Reports and then doing the basic rebuilding did not actually change the number of characters I could enter.
I increased the value of ‘len’ in vardefs.php from 100 to 200 and received a message about this change when rebuilding yet it is not reflected in the report builder.
Can the length be defined somewhere else? A quick review of the other files in the AOR_Reports directory did not identify any other definition.
Where should I look?
Also, if I want to add another type of condition such as using regular expressions in addition to LIKE, where would I need to alter the code? In my experimentation above I had replaced LIKE in AOR _Report.php with REGEXP but it would be preferable to add this condition option while still keeping the ‘Equal to’/LIKE condition?
Ah, I did not see that. I have a lot of labels showing up as “undefined” despite having done a quick rebuild a couple of times. In this case, both AND and OR showed as “undefined” as did the column title…
This should work nicely to extend the query condition capabilities, particularly if I replace LIKE with REGEXP in AOR_Reports.php as I initially did.
Even nicer would be to add REGEXP as another condition operator in addition to EqualTo, Contains, BeginsWith, EndsWith etc.
I reran the scripts below to set permissions but it does not seem to have made any difference:
find /var/www/html/test -type d ! -perm 2755 -exec chmod 2755 {} ;
find /var/www/html/test -type f ! -perm 0664 -exec chmod 0664 {} ;
chmod -R 775 /var/www/html/test/{cache,custom,modules,themes,data,upload}
chmod 775 /var/www/html/test/config_override.php 2>/dev/null
It says apache which is indeed the owner and the group. I am running CentOS 7 and SELinux has tripped me up before so I checked that as well but I cannot find any SELinux violations in the log.
Anything else you can suggest I check? Is the list of directories with 775 permssion above correct or have I perhaps missed any?