Display logo on other entity ??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abidoss
    Senior Member
    • Mar 2023
    • 228

    Display logo on other entity ??

    I have a custom entity called "Partner" that contains multiple companies, and each company has a logo field of type (image). Is it possible to display the logo/image in another custom entity called "Direction"? I tried adding a foreign key field, but the logo field doesn't appear in the selection
  • esforim
    Active Community Member
    • Jan 2020
    • 2204

    #2
    It is possible, which is viewable in the Relationship Bottom Panel. I use it for my Account > Contact. I haven't use Foreign key yet though.

    Maybe someone else can understand what you trying to achieve.

    Comment

    • item
      Active Community Member
      • Mar 2017
      • 1476

      #3
      Hi,
      what kind of relation have you between Partner and Direction
      i don’t know if foreign field work for image.. must check on github

      i think you can achieve this with formula, create a same field in Direction, and set value with same value of Partner.
      image field is just a ID if a attachement. (certainly)
      If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

      Comment


      • abidoss
        abidoss commented
        Editing a comment
        One-to-One Right

      • item
        item commented
        Editing a comment
        Hi Rabii,

        just tested and work like a charm.. every day i am suprised with the power of espoCrm.

      • abidoss
        abidoss commented
        Editing a comment
        can you help me then ?
    • rabii
      Active Community Member
      • Jun 2016
      • 1250

      #4
      you will need to create your own custom field and then another custom field (link) to display the company with its logo on the direction entity.
      Rabii
      Web Dev

      Comment


      • abidoss
        abidoss commented
        Editing a comment
        The custom field in the "Partner" entity has already been created with the type "image". But what type of custom field should I use for the "Direction" entity?

      • rabii
        rabii commented
        Editing a comment
        i meant a custom field (new field) that will use views/fields/image field should implement an upload and an entryPoint to display the field and after that you will need to create a custom link to display the logo near the link name.
    • item
      Active Community Member
      • Mar 2017
      • 1476

      #5
      Hi,

      create same "type" of field.. i have choose "image" .. same "name" i have choose picture, you choose logo...
      just write this in direction entity formula.


      pictureId = partner.pictureId;


      it's all

      You just need to disable "picture/logo" in detail view edit.. make this field conditionnaly read-only.
      There i have see maybe a feature request :
      why we can put conditianaly read-only field image.. but not in option


      Hope Yuri don't see a "design/conception leak".. for me is wonderfull
      Last edited by item; 05-25-2023, 11:47 PM.
      If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

      Comment


      • esforim
        esforim commented
        Editing a comment
        Very cool idea using field ID. This way it doesn't duplicate the file.

      • rabii
        rabii commented
        Editing a comment
        i think it does duplicate the file. i picture will create a new attachment.

      • abidoss
        abidoss commented
        Editing a comment
        thank you very much sir
    • item
      Active Community Member
      • Mar 2017
      • 1476

      #6
      Hi rabii,
      don't see anithing bad, you help many and i use many your tips or code you post.. i will be happy to partage my "little skill"

      there are nothing duplicate with this.
      all file you uploade is a attachment, with entityType, entityId... if you make a print-to-pdf, it create a attachment.. then you can "download" this, if you do a "export xlsx", it create a attachement, and de download link is the attachementId.

      there are 2 direction :

      entity -> attachement
      attachment -> entity.

      in this case,
      Partner have uploaded the Picture.. then there are a attachement : entityType = Partner, entityId=?
      if i go attachment.. i can see => entityType = Partner.

      the solution here.

      Direction.. just "point" to the attachementId of Partner.
      No duplicate.
      it's like a "C++ pointer" .. oufff old learned programming language in school

      Just need, if partner->pictureId change... you must update Direction->pictureId and this is possible with Advanced Pack. (but this is the behaviour of all formula without Advanced Pack or custom code)



      Last edited by item; 05-26-2023, 08:53 PM.
      If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

      Comment


      • esforim
        esforim commented
        Editing a comment
        You can call me coding master now rabii!

        > Very cool idea using field ID. This way it doesn't duplicate the file.

      • esforim
        esforim commented
        Editing a comment
        I finally remember an use for this idea now. I'm currently have "Parent" Account for branch/department. With this trick I should be able to save having duplicate image.
        Last edited by esforim; 06-01-2023, 08:04 AM.

      • rabii
        rabii commented
        Editing a comment
        item if partner is deleted then formula should help. something like below:

        ```

        ifThen(!partnerId && pictureId,
        record\update('Attachmnet', pictureId, 'deleted', true);
        entity\setAttribute('pictureId', null);
        )

        ```

        This way crm will check if we have a pictureId and no partner then delete the attachment.
    • esforim
      Active Community Member
      • Jan 2020
      • 2204

      #7
      Here the code I end up using, nothing fancy:

      Code:
      ifThenElse(accountParent.accountsIds==null, , companyLogoId=accountParent.companyLogoId)
      Interesting rabii show off his skill, he using "!partnerId" which seem to function the same as ==null?

      Being fancy as him I copy, here update.

      Code:
      ifThenElse(
      !accountParent.accountsIds && !companyLogoId && accountParent.agreementsIds=='someIDforspecialaccount' &&, , companyLogoId=accountParent.companyLogoId)​
      Running into many bug and the final code.

      Code:
      ifThen(
      accountParentId!=null && companyLogoId==null && accountParentId!='special_ID_of_Parent', companyLogoId=accountParent.companyLogoId)​
      Last edited by esforim; 06-03-2023, 04:52 AM.

      Comment


      • esforim
        esforim commented
        Editing a comment
        Now I'm updating all my 'branch' Account so logo will shared. The question is...

        My old attachment/logo, does it get delete during some CRON cleanup operation? Or will I have a bunch of 'orphan' photo?
    Working...