YetiForceCompany / YetiForceCRM

Our team created for you one of the most innovative CRM systems that supports mainly business processes and allows for customization according to your needs. Be ahead of your competition and implement YetiForce!
https://yetiforce.com
Other
1.74k stars 749 forks source link

[bug] Workflows Error when task was executed during record creation #12782

Closed allyh12 closed 4 years ago

allyh12 commented 4 years ago

🐞 bug report

⁉️ Describe the bug A workflow scheduled with 'Creating a Record' and 'Update Fields' was created. Error message pops up when record was created. However, workflow get executed and fields have been updated.

πŸ”₯ How to trigger the error

  1. Create Workfows/Creating Record/Update Field
  2. Create record in relevant module
  3. Save the record Error pops up image

Steps to reproduce the behavior: everytime when new record is created

πŸ‘Ž Actual Behavior Error Message

yetiforce2

πŸ‘ Expected Behavior No error message

πŸ‘· Testing

πŸ“· Screenshot of configuration

πŸ“ PHP/Apache/Nginx/Browser/CRM Logs

🌍 Your Environment

Environment Version / Name
YetiForce 5.3.0 SP1
Web server (name and version)
PHP
Browser (name and version)
Operating System (name and version)
Database (name and version)
Service Pack version

❓ Additional context

❗️ Inform the community if you solve the problem

mariuszkrzaczkowski commented 4 years ago

logs ?

allyh12 commented 4 years ago

Hi Mariusz,

Thanks for your prompt response.

I'm very sorry for asking some help as I'm new to Yetiforce. Appreciate if you could provide some guidance on getting the logs ready for you.

https://yetiforce.com/en/knowledge-base/documentation/implementer-documentation/item/debugging

I refered to the above link and changed log-errors and display_errors to On in user.ini. Then, I tried to create the record to generate the error again but I still couldn't see those log files.

Thanks.

Regards, Ally

Sent from Outlookhttp://aka.ms/weboutlook


From: Mariusz Krzaczkowski notifications@github.com Sent: Friday, 27 March 2020 2:36 PM To: YetiForceCompany/YetiForceCRM YetiForceCRM@noreply.github.com Cc: allyh12 bengkhim@live.com; Author author@noreply.github.com Subject: Re: [YetiForceCompany/YetiForceCRM] [bug] Workflows Error when task was executed during record creation (#12782)

logs ?

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/YetiForceCompany/YetiForceCRM/issues/12782#issuecomment-604839517, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOHVI6AYR2JO253J3Y45ZJ3RJRCOFANCNFSM4LUX7YQA.

allyh12 commented 4 years ago

Hi Mariusz,

I managed to get the system log! Please check if this is sufficient.

Thanks, Ally

Sent from Outlookhttp://aka.ms/weboutlook


From: Allison Ho bengkhim@live.com Sent: Friday, 27 March 2020 3:19 PM To: YetiForceCompany/YetiForceCRM reply@reply.github.com Subject: Re: [YetiForceCompany/YetiForceCRM] [bug] Workflows Error when task was executed during record creation (#12782)

Hi Mariusz,

Thanks for your prompt response.

I'm very sorry for asking some help as I'm new to Yetiforce. Appreciate if you could provide some guidance on getting the logs ready for you.

https://yetiforce.com/en/knowledge-base/documentation/implementer-documentation/item/debugging

I refered to the above link and changed log-errors and display_errors to On in user.ini. Then, I tried to create the record to generate the error again but I still couldn't see those log files.

Thanks.

Regards, Ally

Sent from Outlookhttp://aka.ms/weboutlook


From: Mariusz Krzaczkowski notifications@github.com Sent: Friday, 27 March 2020 2:36 PM To: YetiForceCompany/YetiForceCRM YetiForceCRM@noreply.github.com Cc: allyh12 bengkhim@live.com; Author author@noreply.github.com Subject: Re: [YetiForceCompany/YetiForceCRM] [bug] Workflows Error when task was executed during record creation (#12782)

logs ?

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/YetiForceCompany/YetiForceCRM/issues/12782#issuecomment-604839517, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOHVI6AYR2JO253J3Y45ZJ3RJRCOFANCNFSM4LUX7YQA.

z0lo13 commented 4 years ago

@MacarenaReina @allyh12 @mariuszkrzaczkowski its same issue as https://github.com/YetiForceCompany/YetiForceCRM/issues/12768

the issue is with only VTUpdateFieldsTask with recordModel->save()

particularly with

public function getEventHandler(): App\EventHandler
    {
        if (!$this->handler) {
            $this->handler = (new \App\EventHandler())->setRecordModel($this)->setModuleName($this->getModuleName());
        }
        return $this->handler;
    }

if you replace

$eventHandler = $this->getEventHandler();

with

$eventHandler = new App\EventHandler();
        $eventHandler->setRecordModel($this);
        $eventHandler->setModuleName($moduleName);

everything the record saves just fine but it may break the additional validation implemented in https://github.com/YetiForceCompany/YetiForceCRM/commit/028601e97fd9c537e49890af4c97ec99f0448ac9#diff-b7da741f3a161a40feb12e45abc510eb

zazy commented 4 years ago

This happens in gitstable too, just tested. It appears that YetiForce tries to save the same record two times getting a duplicate key error from the database engine. If I disable the workflow that bind to "On create" all works fine. Also the Every time a record is created bind causes the same error.

I noticed that this happens if the workflow tries to modify the just created record. If I use the same worflow but I change the field to modify from the same module to a related module all works fine

P.S.: For anyone looking for a solution and want to test a patch, I posted one to the issue #12768