This is cool!
Thanks.
Check if the relationship panel is populated from Javascript.
Collapse
X
-
Variant:
Make not storable field (entityDefs)
Code:"haveWinQuote": { "type": "bool", "readOnly": true, "notStorable": true }, "haveHarmonizationQuote": { "type": "bool", "readOnly": true, "notStorable": true },
and code like this
PHP Code:namespace Espo\Custom\Services; use \Espo\ORM\Entity; class Opportunity extends \Espo\Modules\Sales\Services\Opportunity { public function loadAdditionalFields(Entity $entity) { parent::loadAdditionalFields($entity); $winQuote = $this->getEntityManager()->getRepository('Quote')->where([ 'opportunityId' => $entity->id, 'status' => 'Won' ])->findOne(); $entity->set('haveWinQuote', !empty($winQuote)); $harmonizationQuote = $this->getEntityManager()->getRepository('Quote')->where([ 'opportunityId' => $entity->id, 'status' => 'In Review' ])->findOne(); $entity->set('haveHarmonizationQuote', !empty($harmonizationQuote)); } }Leave a comment:
-
Check if the relationship panel is populated from Javascript.
How do I check if a relationship panel is populated for an entity from JS to have some front end validations.
I have an entity A with a relationship of 1:M with another entity B. And I have the relationship panel which shows the B entities that are linked to A under the detail view of entity A. I need a way to check if there are any B entities linked to A, so that I can enable/disable a certain button.
How do I go about this using Javascript?
Thank you! Cheers!
@telecastg

Leave a comment: