
NamingConvention on Documents/DocumentFolder => Hook - afterSave + related-entities
Collapse
X
-
Ok thanksgoing to try to dig into the code and other examples to check how i could do that!
-
Nothing impossibleSet the view of your field in entotyDefs, define the template and data you need to pass.
Leave a comment:
-
In my custom entity called "BusinessOpportunity", is there a way to display a custom field (like a dashlet) to display all the documentFolder + Documents closed to my BusinessOpportunity ?
ThanksLeave a comment:
-
If you change target entity and it will be shown after process ending, is better to set link name fields (as parentName). But, if your modified entity is not target (not BusinessOpportunity in your case, but DocumentFolder), and it will be read later, you can ignore setting of link name fields. They will be loaded, when entity be readLeave a comment:
-
Thanks a lot !
I manage to get it worked in the meantime with these following code
PHP Code:foreach ($folders as $folder_name) {
$folder = $this->getEntityManager()->getEntity('DocumentFolder');
$folder->set('name', $folder_name);
$folder->set('parentId', $folder_top_level_id);
$folder->set('parentName', $name);
$this->getEntityManager()->saveEntity($folder);
}
and I saw that the attribute parentName was also set (but not in your code example).
Is it mandatory ? should i expect any troubles if i dont set it ?
Leave a comment:
-
Hello
EspoCRM Documentation. Contribute to espocrm/documentation development by creating an account on GitHub.
something likePHP Code:////in afterSave method
$topFolder = $this->getEntityManager()->getEntity('DocumentFolder');
$topFolder->set('name', $entity->get('nomInterne'));
$this->getEntityManager()->saveEntity($topFolder);
$subFolder1 = $this->getEntityManager()->getEntity('DocumentFolder');
$subFolder1->set('name', 'subFolder 1');
$subFolder1->set('parentId', $topFolder->id);
$this->getEntityManager()->saveEntity($subFolder1);
///
Leave a comment:
-
NamingConvention on Documents/DocumentFolder => Hook - afterSave + related-entities
Hi there
i have a custom entity called "BusinessOpportunity" with an attribute called "internalName"
Every time that a new "BusinessOpportunity" is created, i'd like to prepare an expected DocumentFolder hierarchy to put their all the document related to this entity BusinessOpportunity.
I have created a hook... with a beforeSave function to force the internalName in uppercase.
PHP Code:class Base extends \Espo\Core\Hooks\Base
{
// beforeSave | afterSave | beforeRemove | afterRemove
// if ($entity->isNew())
public function beforeSave(Entity $entity)
{
$entity->set('nomInterne', strtoupper($entity->get('nomInterne')));
}
}
Top-level Document Folder = $BusinessOpportunity->internalName
Then, sub-folders (subfolder1, subfolder2)
Ex:
For a BusinessOpportunity row with internalName = "Example 1",
I want to create a DocumentFolder hierarchy to put there my future documents:
Example 1
... -> subfolder1
.... -> subfolder2
Any clues about how to do my afterSave webhook to create this related-entities rows ?
I check an example between Cases and KnowledgeBaseArticles (cf http://forum.espocrm.com/forum/devel...elated-entites)
but i have some issues to make what i want.
Thanks for your help
Tags: None
Leave a comment: