I know that this way of changing the database isn't very conventional.
However in this case i just need to create Boolean Flags for every line of data i get from a third party API.
I understand your concern, it's just a very specific requirement we have for our current project.
Announcement
Collapse
No announcement yet.
Add Fields to an Entity in Code
Collapse
X
-
strange request...
A database must be under control (security, integrity, conception, design,...).. i can't imagine give the opportunuity to a API to create field and so in database.
for me, you have :
if (!$entity->hasAttribute($value)) reject all ! create task and assign to someOne.
And what about rebuild ?
And what about reserved word .. in espoCRM, in database ..
And what about camelCase ?
it's just my opinionLast edited by item; 10-19-2021, 05:53 PM.
- Likes 2
-
You can try to duplicate how fields are created in the Admin GUI, check this link https://github.com/espocrm/espocrm/b...eldManager.php
- Likes 1
Leave a comment:
-
I took a quick look into your suggested thread. It seems i could potentially create and alter Entity Field definitions by appending the metadata .json File. As i see it however there is no clean way of adding a Field to an Entity in PHP Code itself.
Ideally i am looking for something like this:
PHP Code:$entityManager = $this->getEntityManager();
$entityManager->getRepository($enitity)->addField("int", "counter", {options})
Leave a comment:
-
Hi m.mayer,
In this case, that article may come in handy:
Leave a comment:
-
Sorry, i meant the Entity Manger in PHP Code. I am familiar with creating Fields in the GUI. I also know how to read and write data with the PHP Entity Manager. I had the impression there was a possibility to create Fields via PHP Code for a specific Entity.
I need to update the Fields of a specific Entity according to a third party API.
Leave a comment:
-
If you are not familiar with the Entity Manager I recommend that you read this as well: https://docs.espocrm.com/administration/entity-manager/
- Likes 2
Leave a comment:
-
Hi m.mayer,
Hope, this thread will be helpful:
- Likes 1
Leave a comment:
-
Add Fields to an Entity in Code
Is there a way to add Fields to an Entity via the Entity Manager. I think i saw documentation about this somewhere. I can't seem to find it right now though. I could be mistaken as well.Tags: None
Leave a comment: