How to add CustomerAccount fields to the attachmant screen

Hello Guys, I am a beginer in Dynamice 365 FO. I encountered a problem during practice. My English is really not good so my expression may not be clear enough, please forgive me.:pray:

Now I have a practical training session, I only need the last step now to complete it.

I now need to automatically populate in the Customer Account associated with this attachment to the specified field on the attachment screen.

Just like this.

I found that the DocuAttachment table has two data sources, DocuRef and DoceValue. But I don’t know which fields are needed to achieve the effect I mentioned.

Does the CustomerAccount field exist in the data source? Or do I need to retrieve this field from another table?

This sounds like a bad idea to me. These tables and the form are used for all attachments, therefore they usually have nothing to do with customers. For example, if I attach documents to items, there is no customer associated and showing the useless, empty customer account number on each attachment just make the UI confusing.

What business problem are you trying to address by adding Customer Account to attachments? Most likely, there is a better solution.

Oh, then maybe I can change the scheme to: display the ID value of any item associated with this attachment in this field? Not just the customer, if this attachment is associated with a purchase order, then show the id of the purchase order?
I wonder if this plan is feasible.

MartinDrab via Dynamics User Group <notifications@dugusers.discoursemail.com> 于 2024年5月16日周四 下午7:20写道:

I still wonder what it would be good for. If I open attachments linked to an order, I already know the order ID, so this wouldn’t give me any information.

If you want to do it anyway, you need decide how you’ll determine which field you’d want to show. I think a good choice would be displaying the AutoIdentification field group. Just don’t forget that it may consists of several fields or something useless to users (e.g. RecId, or InventTransId as on PurchLine).

I think you’d use a data source for Common table and assign the actual table at runtime, which is not completely trivial. Again, I would consider whether the whole thing is worth all the effort.

Oh my goodness, I have encountered a new problem again.

As shown in the screenshot, I have added a new tab page here

But when I rebuilt the project and opened the browser, the new tab page didn’t seem to take effect

I didn’t hide this tab page, but it didn’t display properly. What could be the problem?

Please don’t change the topic - your last question isn’t about How to add CustomerAccount fields to the attachmant screen. Simply create a new thread (with an appropriate title and tags) for the other question. We’ll discuss it there.

Sorry, I will create a new thread later to discuss this issue, let’s go back to the initial topic😂. So can I obtain the ID value of the item associated with this attachment from the data source in the attachment table? My practical exercise topic may require me to obtain some information about the items associated with the attachment and display it in the attachment form. My idea now is to use the ID of the item associated with the attachment to query the relevant data

As I said, saying “the ID” is misleading, because not every table has records identified by an ID, it may be a combination of several fields and sometimes the information is useless to users (e.g. RecId 8768070980). I gave you an idea how to get the right fields.

You also need to find the source record. DocuRef table has RefCompanyId, RefTableId and RefRecId fields, which identify the source table and the source record, plus the company where it is. Depending on how you’ll implement your solution, DocuRef.refCommon() may be useful.

It’s going to be pretty complex; not really appropriate for a beginner.

I just tried again and found that the AccountNum value can be obtained from the CustTable table through the RefRecId field. With the AccountNum value, I can obtain more data that I need. Thank you for your guidance, these experiences have benefited me greatly