Menu
Welcome, Guest
Username: Password: Remember me

TOPIC: Extension of save function of in standard (AOS_)module

Extension of save function of in standard (AOS_)module 3 months 3 days ago #82123

  • mojito1985
  • mojito1985's Avatar
  • Offline
  • New Member
  • Posts: 3
  • Karma: 0
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:
  1. The remap of the $beanFiles of the AOS_Contracts.ext.php : Results into an error:
    [PHP Parse error: syntax error, unexpected 'parent' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /custom/modules/AOS_Contracts/AOS_Contracts.php on line 90, referer: https:/ /our.url/index.php?action=ajaxui]
    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
  2. 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:
Custom/Extension/application/Ext/Include/AOS_Contract.ext.php:
<?php
$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
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once("modules/AOS_Contracts/AOS_Contracts.php");
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  :)
      parent::save($check_notify);
   }   
 }

I'm looking forward to your ideas!
Thanks in advance.
Best,
Marcel
The administrator has disabled public write access.

Extension of save function of in standard (AOS_)module 2 months 4 weeks ago #82239

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 10526
  • Thank you received: 1567
  • Karma: 360
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?

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.

Extension of save function of in standard (AOS_)module 2 months 3 weeks ago #82311

  • mojito1985
  • mojito1985's Avatar
  • Offline
  • New Member
  • Posts: 3
  • Karma: 0
Hi,
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 10.211.54.70:5460] 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: myurl.com/index.php?action=ajaxui
The administrator has disabled public write access.

Extension of save function of in standard (AOS_)module 2 months 3 weeks ago #82324

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 10526
  • Thank you received: 1567
  • Karma: 360
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.

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.

Extension of save function of in standard (AOS_)module 2 months 3 weeks ago #82591

  • mojito1985
  • mojito1985's Avatar
  • Offline
  • New Member
  • Posts: 3
  • Karma: 0
Hi.
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.
<?php
require_once('modules/AOS_Contracts/AOS_Contracts.php');
class customAOS_Contracts extends AOS_Contracts {
  function save($check_notify = false) {
      $this->description = "Hallo Welt!";
      $return_id = parent::save($check_notify);
      return $return_id;
  }   
}

and
<?php
$beanList['AOS_Contracts'] = 'customAOS_Contracts';
$beanFiles['customAOS_Contracts'] = 'custom/modules/AOS_Contracts/customAOS_Contracts.php';
[php7:error] [pid 22498] [client 10.211.54.70:26080] PHP Fatal error: Smarty error: [in cache/themes/modules/AOS_Contracts/DetailView.tpl line 233]: syntax error: unbalanced parenthesis in if statement (Smarty_Compiler.class.php, line 1286) in /var/www/html/crm/include/Smarty/Smarty.class.php on line 1100, referer: my.crm/crm/index.php?action=ajaxui
[php7:notice] [pid 22509] [client 10.211.54.70:26114] PHP Notice: Undefined index: customAOS_Contracts in /var/www/html/crm/include/TemplateHandler/TemplateHandler.php on line 310, referer: my.crm/crm/index.php?action=ajaxui
[php7:error] [pid 22509] [client 10.211.54.70:26114] PHP Fatal error: Smarty error: [in cache/themes/modules/AOS_Contracts/SearchForm_basic.tpl line 103]: syntax error: unrecognized tag: $fields..value (Smarty_Compiler.class.php, line 448) in /var/www/html/crm/include/Smarty/Smarty.class.php on line 1100, referer: my.crm/crm/index.php?action=ajaxui

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

Thanks and best
Marcel
The administrator has disabled public write access.

Extension of save function of in standard (AOS_)module 2 months 2 weeks ago #82625

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 10526
  • Thank you received: 1567
  • Karma: 360
This similar issue that you linked on Github provides a suggested solution, maybe you can try it...

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.
Time to create page: 0.042 seconds
Powered by Kunena Forum