Announcement

Collapse
No announcement yet.

Entity sharing

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Entity sharing

    Is there any way I can get one entities field to show up in another entity as well?
    For example, if I had a phone number sitting under accounts can I get that same number to show up in a case?

  • #2
    Try add the foreign field
    Attached Files

    Comment


    • esforim
      esforim commented
      Editing a comment
      Yep, that how you would do that, unfortunately with Phone Numbers it will only show the Primary (star) numbers, same with the Account.

      Alternatively you can also take advantage of adding it as a Bottom Panel in your layout. From there you can add column that it will be able to display. Unfortunately Bottom Panel doesn't work for Small view (side panel), so you would have to rely on Foreign Field for that.

  • #3
    It's not very pretty, but it works.

    1. Add not storable field:

    Code:
     "accountPhoneData": {
          "readOnly": true,
          "type": "text",
          "isCustom": true,
          "notStorable": true
    }
    where accountPhone is the foreign field name

    2.

    To custom service/entity.php add

    PHP Code:
    public function loadAdditionalFields(Entity $entity)
    {
       
    parent::loadAdditionalFields($entity);
       
    $account $entity->get('account');
       
    $dataAttributeName 'accountPhoneData';
       
    $phoneNumberData $this->getEntityManager()->getRepository('PhoneNumber')->getPhoneNumberData($account);
       
    $entity->set($dataAttributeName$phoneNumberData);
       
    $entity->setFetched($dataAttributeName$phoneNumberData);


    Maybe yuri will suggest a more beautiful solution
    Last edited by dimyy; 08-27-2021, 07:17 AM.

    Comment

    Working...
    X