Hi, as said in the Topic i want to create a custom entity via GET.
I'm quite new at this, so i dont know how specific I have to be.
What i have:
The table 'TestMensch' is of type Person and does have standard attributes.
I have some code, taken and adapted from one of the other forum entries.
<?php
namespace Espo\Modules\Crm\EntryPoints;
use \Espo\Core\Exceptions\NotFound;
use \Espo\Core\Exceptions\Forbidden;
use \Espo\Core\Exceptions\BadRequest;
class MyCreateEntityEntryPoint extends \Espo\Core\EntryPoints\Base
{
public static $authRequired = false;
public function run()
{
$type = $_GET['entityName'];
$entity = $this->getEntityManager()->getEntity($type);
$entity->set('assignedUserId', "system");
if ($type == 'TestMensch') {
$entity->set('salutationName', $GET['anrede']);
$entity->set('firstName', $_GET['vorname']);
$entity->set('lastName', $_GET['nachname']);
}
$this->getEntityManager()->saveEntity($entity);
}
}
?>
This is put in "Espo\Modules\Crm\EntryPoints"
I get a 404 Page Not Found Error Message after trying following url
http://myEspo/?entryPoint=myCreateEn...nachname=Bower
I only send these 3 attributes in because in the crm userinterface thats the only required fields and the rest got filled up with nothing or automatically.
Another way would be to simply take the Create Entity function from the api, but i dont know what a payload is, how to create one and how to implement it.
Questions:
1. Do i need to send all attributes always even if its not filled?
note: I did saw the api call in the developer thingy (f12), in which all the attributes were given(even if it was empty), when i created an entity with only these 3 attributes.
2. What caused the Error exactly and what can I do to make it work?
3. Can I get a little introduction on payloads, which covers the points mentioned above (optimally with examples)? A beginnerfriendly link should also be enough.
Thanks in advance for the help.
I'm quite new at this, so i dont know how specific I have to be.
What i have:
The table 'TestMensch' is of type Person and does have standard attributes.
I have some code, taken and adapted from one of the other forum entries.
<?php
namespace Espo\Modules\Crm\EntryPoints;
use \Espo\Core\Exceptions\NotFound;
use \Espo\Core\Exceptions\Forbidden;
use \Espo\Core\Exceptions\BadRequest;
class MyCreateEntityEntryPoint extends \Espo\Core\EntryPoints\Base
{
public static $authRequired = false;
public function run()
{
$type = $_GET['entityName'];
$entity = $this->getEntityManager()->getEntity($type);
$entity->set('assignedUserId', "system");
if ($type == 'TestMensch') {
$entity->set('salutationName', $GET['anrede']);
$entity->set('firstName', $_GET['vorname']);
$entity->set('lastName', $_GET['nachname']);
}
$this->getEntityManager()->saveEntity($entity);
}
}
?>
This is put in "Espo\Modules\Crm\EntryPoints"
I get a 404 Page Not Found Error Message after trying following url
http://myEspo/?entryPoint=myCreateEn...nachname=Bower
I only send these 3 attributes in because in the crm userinterface thats the only required fields and the rest got filled up with nothing or automatically.
Another way would be to simply take the Create Entity function from the api, but i dont know what a payload is, how to create one and how to implement it.
Questions:
1. Do i need to send all attributes always even if its not filled?
note: I did saw the api call in the developer thingy (f12), in which all the attributes were given(even if it was empty), when i created an entity with only these 3 attributes.
2. What caused the Error exactly and what can I do to make it work?
3. Can I get a little introduction on payloads, which covers the points mentioned above (optimally with examples)? A beginnerfriendly link should also be enough.
Thanks in advance for the help.
Comment