"on Page load" Hook
Collapse
X
-
-
Thank you. I cannot find the sub directory Espo\Custom\Reources\metadata\recordDefs\ , do I just need to create this directory and the Connection.json?Given your example i assume your custom entity is called connection, try the steps below:
1 - Create your php file under Espo\Custom\Hooks\Connection\BeforeReadConnectionC heck.php
PHP Code:<?php namespace Espo\Custom\Hooks\Connection; use Espo\Core\Record\Hook\ReadHook; use Espo\Core\Record\ReadParams; use Espo\ORM\Entity; /** * @implements ReadHook<\Espo\Custom\Entities\Connection> */ class BeforeReadConnectionCheck implements ReadHook { public function process(Entity $entity, ReadParams $params): void { $entity->set([ 'status' => 'Read', 'description' => 'Status has been set as Read via ReadHook' ]); } }
2 - map the file on the recordDefs under Espo\Custom\Reources\metadata\recordDefs\Connectio n.json
PHP Code:{ "beforeReadHookClassNameList": [ "Espo\\Custom\\Hooks\\Connection\\BeforeReadConnectionCheck" ] }
This should work fine, tested.Leave a comment:
-
Given your example i assume your custom entity is called connection, try the steps below:
1 - Create your php file under Espo\Custom\Hooks\Connection\BeforeReadConnectionC heck.php
PHP Code:<?php namespace Espo\Custom\Hooks\Connection; use Espo\Core\Record\Hook\ReadHook; use Espo\Core\Record\ReadParams; use Espo\ORM\Entity; /** * @implements ReadHook<\Espo\Custom\Entities\Connection> */ class BeforeReadConnectionCheck implements ReadHook { public function process(Entity $entity, ReadParams $params): void { $entity->set([ 'status' => 'Read', 'description' => 'Status has been set as Read via ReadHook' ]); } }
2 - map the file on the recordDefs under Espo\Custom\Reources\metadata\recordDefs\Connectio n.json
PHP Code:{ "beforeReadHookClassNameList": [ "Espo\\Custom\\Hooks\\Connection\\BeforeReadConnectionCheck" ] }
This should work fine, tested.Leave a comment:
-
Hi,
You can use the before-read record hook: https://docs.espocrm.com/development...kclassnamelist. It executes on read API call.
Thanks for the suggestion. I've tried some sample code:
https://pastebin.com/1RBR9GrW
But it does not seem to work. Is there any working implementation that you can share?Leave a comment:
-
Hi,
You can use the before-read record hook: https://docs.espocrm.com/development...kclassnamelist. It executes on read API call.Leave a comment:
-
"on Page load" Hook
Hi,
is there any possiblity to Hook into the page load from PHP?
I'd like to set certain fields when the user loads a certain Object.
JavaScript is not an option, it must be PHP.Tags: None

Leave a comment: