"PEN" edit icon does not behave as the regular edit Button ?

Building a trigger so when a user modify an account it automatically creates a related case for the account.
Obviously there are more logic/conditions involved but I removed them for the sake of finding where my problem resides and
I found that if you edit the account using the pen icon, the created case is not related to the accountā€¦

So here is my simplified function :

   
function CheckAccountTypes(&$bean, $event, $arguments) {
        global $current_user;
        global $db;

        try {
            $newCase = BeanFactory::newBean('Cases');
            $newCase->state = 'Open';
            $newCase->status = 'Open_New';
            $newCase->type = 'Administration';
            $newCase->name = 'test pour Serge '. date('H:i:s', time());
            $newCase->description ='this is a test' ;
            $newCase->save();
        }
        catch (Exception $e){
            $GLOBALS['log']->fatal("log " .__FUNCTION__." $e ".__LINE__);
        }
    }

My problem is not with the hook, because it triggers all right, when saving the account, I create a new case.
BUT
[ul]
[li]When I begin the process with the Edit button the created case is related to the account.
[/li]- When I begin the process with the Pen icon from the left last viewed list, the newly created case is NOT related to the account.

(post edit) I tested creating a new account and the case is NOT related to the accountā€¦

Is it me that does not understand how it works or is this a bug that I need to report?

Thank you

Why are just not using the WorkFlow module?

What type of hook are you using? if is an after_save, thereā€™s no logical explanation why this is happening to you, the pencil or edit button do the same thing, edit that entry and then you call the save method

best regards

it is after_saveā€¦

I already looked at workflow and using it when I canā€¦
I would need to build many workflow to dispatch the created case to the right person, depending on country the case could be assigned to 5 different personsā€¦
so I am afraid of performance issue having so much workflow vs a simple fileā€¦
and my most important problem with workflow is the related drop down supportā€¦

Background info: our ERP drops / update informations in CRM and create accounts when needed, special fields are also usedā€¦

After a CRM user save the account, I need to compare 2 fields that the ERP drops in the accounts and compare it to 2 dropdown one being relatedā€¦
like ERP customer type = ā€˜Privateā€™ then CRM drop down is ā€˜Privateā€™
and ERP customer subtype ā€˜Studentā€™ then CRM drop down is ā€˜Private_Studentā€™ā€¦
the hook watch if the ERP fields no longer match the CRM fields after save (a user changed either drop down values) then a case is triggered to ask CSRā€™s people to modify or update the ERP recordā€¦ since my salesperson in the fields does not have access to ERP and CSRā€™s doesā€¦

I would be really surprised if this is achievable via workflowā€¦ but ā€œeasilyā€ controlled via php if the pen icon would behave correctlyā€¦

I believe more operators in the workflow module might handy like ā€œis not nullā€, strlen >, etcā€¦

I am open to ideasā€¦
ā€¦ and if this is really a bug then it is dangerous for unwanted behaviorā€¦

yes, logical operators are very much needed in the WorkFlow module, let me test this in my environment, is really weird the thing about the pencil and the edit button, is not logical but who knowsā€¦ can you post your system settings so I can match it?

are you populating SuiteCRM via web service with your ERP? just to clarify, logic_hooks only triggers if is done via the application it self (browsing it) or via web service, not via sql commands or something like that.

best regards

suitecrm 7.5.3 will try to update over the week endā€¦
php 5.6.22 IIs running on my dev machine windows 10
sql server 2012

the erp is updating sql directly via our own querieis, when we implemented this 5 years ago I was not at ease with soapā€¦

thank you Mike for trying to make sense of thisā€¦

hello Mike,

oups, not running 7.5.3 but 7.6.5 !

do you need other information about my setup?