Extension of save function of in standard (AOS_)module

Hi everyone!

The Background (Why?): I have to match a record POST via the API to an existing record (if already created) via a business key. If not existing we have to create a new record.
(We can’t use the PATCH method caused by the source system that is not able to differentiate between create or update)
Therefore I extended the save function in the module.php class of all our custom modules. This is working pretty good (So this is not the problem :)) and it is upgrade save due to the fact I implemented it in the module build.
But I’m also using the AOS_Contracts, AOS_Products and AOS_Product_Categories and Cases Modules.

With these standard modules I need some help / assistance for an upgrade save possibility because:
[li]The remap of the $beanFiles of the AOS_Contracts.ext.php : Results into an error:

So we changed for an intermediate (but not upgrade safe) solution the include/modules.php $beanfiles Path of AOS_contracts to the custom/…/customAOS_Contracts.php[/li]1. A new records get created, but the changed save function didn’t execute. So the discription as a check, didn’t update

What I did:
Here is the module extension to call the custom class:

$beanList['AOS_Contracts'] = 'CustomAOS_Contracts';
$beanFiles['CustomAOS_Contracts'] = 'custom/modules/AOS_Contracts/customAOS_Contracts.php';

And the Extension in custom/modules/AOS_Contracts/customAOS_Contracts.php

if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class CustomAOS_Contracts extends AOS_Contracts {
    public function save($check_notify = false)
      $this->description = "Hello world! I live!";
       // so here follows the matching magic that is working in the custom modules  :)

I’m looking forward to your ideas!
Thanks in advance.

Maybe it’s better if we just debug the error you got (PHP Parse error: syntax error, unexpected ‘parent’ etc), can you post the exact code that was throwing that error?

currently I get this error. For the record: I removed the “public” in front of the function save.

[Wed Apr 24 07:53:11.446308 2019] [php7:error] [pid 21695] [client] PHP Fatal error: Smarty error: [in cache/themes/myTheme/modules/AOS_Contracts/DetailView.tpl line 233]: syntax error: unbalanced parenthesis in if statement (Smarty_Compiler.class.php, line 1286) in /include/Smarty/Smarty.class.php on line 1100, referer: https://myurl.com/index.php?action=ajaxui

These are just PHP syntax errors, they should be easy to solve. But if you want my help help with this you will have to show the code that is throwing the error. This problem is coming from changes you made to the source files.

Thanks for coming back to my topic. I didn’t chanded anything at the source file of the core module, I only added some custom fields with the studio.

It’s just the two files i worte in my topic.

class customAOS_Contracts extends AOS_Contracts {
  function save($check_notify = false) {
      $this->description = "Hallo Welt!";
      $return_id = parent::save($check_notify);
      return $return_id;


$beanList['AOS_Contracts'] = 'customAOS_Contracts';
$beanFiles['customAOS_Contracts'] = 'custom/modules/AOS_Contracts/customAOS_Contracts.php';

I found a similar case: https://github.com/salesagility/SuiteCRM/issues/7149

Thanks and best

This similar issue that you linked on Github provides a suggested solution, maybe you can try it…