web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Document attachment entities cross company

(2) ShareShare
ReportReport
Posted on by 158
Hi!
 
In Finance and Operations there are some default out-of-the-box document attachment entities, for example for Customer (CustomerAttachmentsV2Entity). However, they are not programmed to support cross company attachments. Is there anyone who could think of why this functionality is not included? Is there a risk or problem by doing that?
 
Thanks and regards!
Categories:
I have the same question (0)
  • Sohaib Cheema Profile Picture
    49,024 User Group Leader on at
    Document attachment entities cross company
    Hi
     
    There is a field named LegalEntityId in this entity. Could you check it out of that works for you? As for the primary key is based on Document ID.
     
     
  • hca Profile Picture
    158 on at
    Document attachment entities cross company
    To be more specific, the OData request for the document returns a result, but the content of the file is empty because the file content is in another company.
     
    Here is a typical attachment entity logic that fetch the file. The select statement needs to go cross company to return results from other companies.
    /// <summary>
    /// Entity used to Dual-Write document attachments for the <c>CustomerAttachmentsV2Entity</c> table.
    /// </summary>
    public class CustomerAttachmentsV2Entity extends common
    {
        /// <summary>
        /// Populates virtual fields.
        /// </summary>
        public void postLoad()
        {
            super();
            // Virtual fields are not auto-populated from the base entity, so an extra select is necessary.
            if (this.RecId && this.DocumentId != emptyGuid())
            {
                DocuRefEntity baseEntity;
                select firstonly baseEntity where baseEntity.DocumentId == this.DocumentId;
                this.FileContents = baseEntity.FileContents;
                this.fieldExternallySet(fieldNum(CustomerAttachmentsV2Entity, FileContents), false);
            }
        }
    }
  • Sohaib Cheema Profile Picture
    49,024 User Group Leader on at
    Document attachment entities cross company
    Hi,
     
    I have checked it.
     
    This data entity has a value for property named PrimaryCompanyContext because of which it cannot operate cross-company
     
     
    it is an out of the box entity
  • hca Profile Picture
    158 on at
    Document attachment entities cross company
    Thank you Sohaib, yes it is out of the box and it does not support cross company. I'm wondering why they may have done this. Was it not considered, or is there some drawback to allow cross company in a custom attachment entity?
  • Suggested answer
    Sohaib Cheema Profile Picture
    49,024 User Group Leader on at
    Document attachment entities cross company
    Hi @hca
     
    This is normal from Microsoft or any vendors to deliver out-of-box data entities that can work in a single company only. I can understand your pain of running it multiple times (once for every entity). It is up to Microsoft; when they create a new data entity, they can decide to make it company-specific or cross-company. You never know, in the near future they may release an updated version of the same entity where cross-company becomes possible.
     
    However, I will not make a big fuss about such a small thing. It is not a big job to make this entity cross-company.
    As the entity CustomerAttachmentsV2Entity is based on another entity (named DocuRefEntity), both of the entities need the value removed from the property PrimaryCompanyContext using extensions, and that is it, the entity would work cross-company.
     
     
    You could also consider duplicating the entity and making changes on the Duplicate Entity, if you do not wish to make changes on the original entity
  • hca Profile Picture
    158 on at
    Document attachment entities cross company
    My issue is that the API client is connected to a specific company, so all my OData queries need to contain the "cross-company=true". Perhaps it's possible to set up a user that is a cross company user, and then the issue is avoided. I'm not sure if that will help from the "postLoad" code point of view. I don't think it will help to just change the property you refer to.
     
    I'm not making a big fuss, but it would have spared a lot of people the work of creating their own entity when the out-of-box would have worked just fine with cross company supported.
     
    edit: Btw. it's my understanding that we should not make changes to the out of box functionality in general, I would avoid that.
  • Sohaib Cheema Profile Picture
    49,024 User Group Leader on at
    Document attachment entities cross company
    Hi @hca
     
    To be honest, it is entirely up to you in terms of which solution you want to proceed with.

    As for your question about the entities' behavior in the context of company data sharing, it is as I mentioned.
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 765 Super User 2025 Season 2

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 743

#3
Sumit Singh Profile Picture

Sumit Singh 551

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans