On a suitecrm Version 8.5.1 instance
I have two custom modules with a one-to-many relationship and when I try to create an instance of one of the modules using the create button in the subpanel I get this message
Error occurred while saving record
In the browser console I have this message
Object { stack: "2306/l/o<@https://manager.crm.com/dist
node_modules_rxjs_dist_esm_operators_index_js.a98e8621cd8e780a.js:1:49021\n6149/r<
<@https://manager.crm.com /dist
node_modules_rxjs_dist_esm_operators_index_js.a98e8621cd8e780a.js
1:47717\n_throwIfClosed@https://manager.crm.com/dist
node_modules_rxjs_dist_esm_operators_index_js.a98e8621cd8e780a.j s:1:4687\n2013/next
<@https://manager.crm .com/dist
node_modules_rxjs_dist_esm_operators_index_js.a98e8621cd8e780a.js:1:4724\n_@https:/
manager.crm.com/dist/node_modules_rxjs_dist_esm_operators_index_js.a98e8621cd8e780a.js:1:
49471\next@https://manager.crm.com /dist
node_modules_rxjs_dist_esm_operators_index_js.a98e8621cd8e780a.js:1:4710\next@https:/
manager.crm.com/dist/node_modules_rxjs_dist_esm_operators_index_js.a98e8621cd8e780a.js:1:93 7\n4866/initSubpanels/<@https://manager.crm .com/dist/dist_core_fesm2022_core_mjs-_06691.b5115738aefb97e6.js:59:231961\next@https://manager.crm.com/dist/node_modules_rxjs_dist_esm_operators_index_js.a98e8621cd8e780a.js :1…", name: "ObjectUnsubscribedError", message: " object unsubscribed" }
In the logs I cannot identify the error. Could you give me a hint on how to debug or resolve this error?
Update 1
I have set the debug level to Error. When trying to create a record from the subpanel I get the error and in the logs I read this
Mon Apr 8 21:27:01 2024 [2212429][c63f4713-1c6d-01fa-9b90-5aebd487cf5d][ERROR]
ApiBeanMapper field validation | Key 'id' | Error 'Invalid id field
'module_a_module_b_1module_a_ida'. Value not a string nor a number'
Thanks in advance
I get same error, custom module, version 8.6.0 . When i go direct to the module there is no problem creating instance.
I have the same issue on version 8.6.1 with the following error in the response of saveRecord request:
Invalid accep_outlets_leadsleads_ida field value
and when checking the payload I found this attribute as follows:
accep_outlets_leadsleads_ida: [{id: “37465295-222b-5def-be63-66b9a00410f9”, module: “Leads”,…}]
Here’s a solution that worked for me but I didn’t have the time to run full test on it,
edit core\backend\Data\LegacyHandler\RecordHandler.php at line 248
add the below code and edit setFIelds and setUdatedFields
// fix one2many relation save
$attributesToSave = [];
foreach ($record->getAttributes() as $key => $value) {
if (substr($key, -4) === '_ida' && is_array($value)) {
$attributesToSave[$key] = $value[0]['id'];
} else {
$attributesToSave[$key] = $value;
}
}
// replace $record->getAttributes() with $attributesToSave
$this->setFields($bean, $attributesToSave);
$this->setUpdatedFields($bean, $attributesToSave);
$this->save($bean);
pgr
13 August 2024 11:53
5
I believe there is already a fix for this, should be in the next version (8.6.2?)
salesagility:hotfix
← jack7anderson7:fix/466
opened 07:56AM - 23 Jul 24 UTC
## Description
Fix #466
## Motivation and Context
Fix #466
## … How To Test This
See #466
## Types of changes
- [X] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
### Final checklist
- [X] My code follows the code style of this project found [here](https://docs.suitecrm.com/community/contributing-code/coding-standards/).
- [ ] My change requires a change to the documentation.
- [X] I have read the [**How to Contribute**](https://docs.suitecrm.com/community/contributing-code/) guidelines.
1 Like