Workflow on Leads behaviour

Hello fellow SuiteCRM users and programmers.

I have come across a strange issue and hope someone may point me in the right direction, or move this post to the developer section if more appropriate.

  1. I have a workflow that works on the Leads module. It is set to “Always” run on “Modified Records” with “repeated runs”.
    It runs on every Workflow task invocation.

I changed the workflow to run “Only on Save”, on “Modified Records” with “repeated runs”. Now, when I edit the lead that should trigger the workflow, nothing happens; the system log shows

[1][ERROR] fromUser: Conversion of 2018-09-24 23:59:59 from user format d/m/Y H:i failed
[1][ERROR] fromUser: Conversion of 2018-10-24 03:23:16 from user format d/m/Y H:i failed

From a database lookup, these dates are the creation and modification date for the lead that is supposed to trigger (but doesn’t even enough to show a “fail” in the process audit).

I tried the simpler things, such as changing the user format (and system format) (using the user control panel), but this did not help.

A quick look at the code shows 3 uses of fromUser in modules/AOW_WorkFlow/AOW_WorkFlow.php and one in modules/AOW_WorkFlow/aow_utils.php, but I am not sufficiently familiar with DateTime and TimeDate classes to debug this.
Is this the likely source of problems?

I have replicated this in a number of environments, (php 5.6 and SuiteCRM 7.8.22 in TurnKey), (php 7.0 and SuiteCRM 7.8.16 in Ubuntu 16.04.4)

Thank you.

There are two PHP engines in your system: one for Web Server, one for command-line (CLI).

Workflows that are “on save” run from Web server (they start from a UI action), while “On Scheduler” run from cron, which is CLI.

There are two php.ini’s, one for each engine. You probably need to make your timezone configs match between the two, or maybe some other date format option, I don’t know.

Thanks for the input, pgr.

Unfortunately, that didn’t appear to be the problem. I was surprised to find that the timezone was correctly set in all the php.ini to the correct one (which for me is date.timezone = “Australia/Melbourne”).

Any other suggestions?

I think I found the problem:

The definition of “Contains” changes depending on whether the cli or web php is called; which caused the workflow to trigger when called from the cli, but not from apache.

For example, the action

Leads	Last Name	Contains	Value Smith

is triggered from the scheduler, but not from the on save workflow, for a lead whose last name is Smith.

Thanks for the tip of exploring the differences between different php calls, pgr. I’d still like to know why this “Contains” changes based on cgi or cli php invocation though :-).

P.S.: I’ve tested the behaviour exists against the SuiteCRM online demo as well (meaning of contains does not include first character for the “On Save” workflow trigger)

Note that the two PHP’s can be very different, including even different versions of PHP.

I’d like to get to the bottom of this issue, if you can please assist. I would ask you to turn up your log level (in Admin / System settings) to DEBUG and then your full SQL queries will be logged.

So this way you could try both methods and provide us with the two queries for the Smith Leads, so we could check for any difference. Thanks.

Thank you for your interest in this issue, pgr.

I have created a custom AOW Action (although tested the issue with pre-existing modules as well, and against the online demo too)
I have created a lead, last name “Kirk”, and have a Workflow that performs a custom action when it matches condition
1 Leads Last Name Contains Value Kirk

I have 3 debug files, as follows:
1 – workflow being triggered correctly, from scheduler
1 – workflow not being triggered, from OnSave
1 – modified workflow (now searching for “irk”) triggered, from OnSave

Simplest way to find if workflow has triggered is to look for line that says
“[FATAL] Workflow called on object d0790f00-e986-06f1-b82c-5bd2e573c943 Jim Kirk” or just search for Kirk
This is the (log) output of this simple workflow.

1 Like

I can’t find a reason why the Contains clause would behave differently.

Can you please check you php.ini, there you have a definition of where your web server log file goes (php_errors.log perhaps). Check that other log, there could be a PHP error tripping the code.

Error logging was on, but there was no log file set-up. I enabled it (to both php_errors.log and syslog), killall -9 apache2, service apache2 start, and re-run the workflow; I could neither find php_errors.log ( find / |grep php_error.log) nor any entries in the syslog regarding php errors.

Meanwhile attached .txt is a diff between the 2 php.ini files. There are differences, but the memory things could be the only one; and that doesn’t explain why the substring “irk” is matched, while the string “Kirk” is not.

Just to clarify, is the expected behaviour of “Contains” supposed to match the full string or not?

Just a few tweaks to your commands :wink:

service apache restart
find / -name php_errors.log 2>/dev/null

Sometimes when I want to make sure I find php_errors.log I add this line to the beginning (after the license text) of SuiteCRM’s index.php:

$myWarning = 3/0;

This is will make sure a “division by zero” is generated, when you see it in a log file, you know you have the correct log file.

Please search Google for generic solutions about the log file, when you get it working tell me if we have any further clues. This effort is well worth making - it is a critical element of troubleshooting SuiteCRM.

Got the log file working, no worries.

However, there are no entries when the workflow doesn’t get called, (other than the division by zero).

[27-Oct-2018 21:55:02 Australia/Melbourne] PHP Warning: Division by zero in /var/www/suitecrm/index.php on line 45

p.s. “service apache2 restart” is a bit slow to kill things, so that’s why i use killall if that matters.
p.s. 2 ====apache logs
[Sat Oct 27 21:53:13.368400 2018] [ssl:warn] [pid 20727] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sat Oct 27 21:53:13.369098 2018] [ssl:warn] [pid 20727] AH01909: localhost:12322:0 server certificate does NOT include an ID which matches the server name
[Sat Oct 27 21:53:13.441103 2018] [ssl:warn] [pid 20728] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sat Oct 27 21:53:13.441596 2018] [ssl:warn] [pid 20728] AH01909: localhost:12322:0 server certificate does NOT include an ID which matches the server name
[Sat Oct 27 21:53:13.441831 2018] [core:warn] [pid 20728] AH00098: pid file /var/run/apache2/apache2.pid overwritten – Unclean shutdown of previous Apache run?
[Sat Oct 27 21:53:13.445212 2018] [mpm_prefork:notice] [pid 20728] AH00163: Apache/2.4.10 (Debian) OpenSSL/1.0.1t configured – resuming normal operations
[Sat Oct 27 21:53:13.445263 2018] [core:notice] [pid 20728] AH00094: Command line: ‘/usr/sbin/apache2’

Ok, I am convinced you are seeing the correct log :slight_smile:

Can you make this behave differently if you change the Date format in the user’s profile? That date conversion seems to be depending on that.

But this code hasnt been changed in a long time, I can’t imagine why it’s failing like this…

No, the user (or system) time display did not make a difference. It was the first thing I tried.

For a simple test, in the SuiteCRM Online Demo (https://demo.suiteondemand.com), try the following:

Create a WorkFlow for Leads Module, run “Only on Save”, with “Condition” “Last name” “contains” “Greenspan”, with “Action” “ModifyRecord”, “Description” “Touched by a workflow”, then edit the “Lucia Greenspan” record.

The Description won’t change.

Then change the “Condition” to “reenspan”; Save the lead and the Description will change.

Meanwhile (and I can’t test against the online demo since it doesn’t appear to have task scheduler turned on) the cli php that runs from the task scheduler matches the full string as part of the “Contains” condition.

My personal expectation was that “Contains” can include the beginning of the string, not strictly a substring, but only does when called from the scheduler, (and not by the OnSave).

The SQL formed for the “contains” keyword is this

WHERE leads.last_name LIKE CONCAT('%', 'Kirk' ,'%')

Which is correct and should catch name “Kirk” even with the first character.

But for some reason when running from the Scheduler it doesn’t seem to even generate any LIKE clause… as far as I can see from your logs.

I suggest you open an Issue with this on Github, with your “steps to reproduce”. It is surely a bug. Thanks for reporting.

@sergtech please have a look in this Issue, I tried to get some help for you and now some questions arise, it’s useful if you are looking at the comments there. Thanks

https://github.com/salesagility/SuiteCRM/issues/5869#issuecomment-433633609

1 Like

Thanks @pgr. I’ve looked at the github topic and posted there; I don’t think the two are related.

I haven’t yet submitted a new Issue on Github, but I will within a couple of weeks. There are some other issues within the workflow module, related to time calculations and triggers I need to explore first (and get repeatable issues with first).

Thank you again for your continued interest :slight_smile:

1 Like