Skip to main content

Notifications

Community site session details

Community site session details

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

Uploading attachment to current record in Dynamics F&O with the use of ODataUltility library c#

(0) ShareShare
ReportReport
Posted on by 130

Previously I have asked this question here - community.dynamics.com/.../984690,  but

I have some misunderstanding. I was advised to use this sample of code for import from here - github.com/.../DataPackageHandler

1004.Captu64re.PNG

To make it work with Dynamics I must configure azure storage for dynamics in this way - github.com/.../wiki

Is that all that I have to do to make imports to dynamics, so that documents will appear in attachments ?

0456.Capture4.PNG

  • Martin Dráb Profile Picture
    232,871 Most Valuable Professional on at
    RE: Uploading attachment to current record in Dynamics F&O with the use of ODataUltility library c#

    Can you please elaborate what you did? When saying that you added an entity, what does it mean? Where did you add it and how? Please realize that we depend on information and if you don't do your part, we can't help you.

    Also, the first sentence is wrong. The part "I'll have to create a new entity" is correct but "use EcoResDocumentAttachmentEntity or LedgerJournalAttachmentsEntity" is not. Building a new entity and using an existing one are clearly two different things. You were told that you can look at the existing entities for an inspiration on how you can create your new entity.

    Regarding examples, it's not clear what kind of example you want. I thought you wanted to use data management APIs (you have an example in your own above question), but your last screenshot looks like OData. Please explain what you're doing and therefore what examples you're interested in.

  • Dynamics Questions Profile Picture
    130 on at
    RE: Uploading attachment to current record in Dynamics F&O with the use of ODataUltility library c#

    It was mentioned above that in order to create document attachments, I'll have to create a new entity that can do that and use EcoResDocumentAttachmentEntity or LedgerJournalAttachmentsEntity, for instance.

    I used LedgerJournalAttachmentsEntity, after adding this entity, LedgerAttachment class was accessible for use, I thought with the help of that class I will have an opportunity to send files to dynamics f&o.

    The export procedure consists of the following steps:

    1)I collect all data in my environment, I have inputted values to fields and tables for VendorPaymentJournal

    2) After all data is prepared  I send it to dynamics (I showed above screens where all data appeared after I export it to dynamics)

    My aim is to send documents to attachments together with all data (fields, tables). Could you, please, provide link or sample of code, where it's shown how to send files to dynamics from simple Console Application ? What should be used for this ?

  • Martin Dráb Profile Picture
    232,871 Most Valuable Professional on at
    RE: Uploading attachment to current record in Dynamics F&O with the use of ODataUltility library c#

    ... nevertheless I don't see any entity with public name LedgerAttachment (LedgerJournalAttachmentsEntity isn't public at all). Maybe it's something custom, but then I can't comment on its implementation.

    I looked into 10.0.0.5; I'll check a newer application later.

  • Martin Dráb Profile Picture
    232,871 Most Valuable Professional on at
    RE: Uploading attachment to current record in Dynamics F&O with the use of ODataUltility library c#

    Aha, so you're not talking about F&O code - it's a proxy class in the client application, in C#. And the C# method calls the OData action exposed by the data entity.

    Regarding export and import, please distinguish what you're doing at which step and don't use the words interchangeably. Otherwise you don't know what's failing and you can't effectively communicate with others.

    I don't think you ever mentioned how you export the data; you kept talking about calling OData services. Can you please explain your export procedure?

    You should do one thing at a time. If you don't know how to extract the data, don't waste with imports just yet. Solve exports first and only then move to the other step.

  • Dynamics Questions Profile Picture
    130 on at
    RE: Uploading attachment to current record in Dynamics F&O with the use of ODataUltility library c#

    I want to import data do dynamics, by exporting data from my environment.
    I need to send files to dynamics

    This is the class, which I mentioned 

    ld.PNG

  • Martin Dráb Profile Picture
    232,871 Most Valuable Professional on at
    RE: Uploading attachment to current record in Dynamics F&O with the use of ODataUltility library c#

    Don't you confuse works "export" and "import"?

    You said that you wanted data to appear in an AX form after you export them from an environment, but that would require an import.

    Also, the error you get suggests that you're actually importing (conflicting) data, despite that you said you're making export.

    Why exactly do you want to use some classes instead of data entities, as we suggested? I even didn't see LedgerAttachment class in my application - what it is?

  • Dynamics Questions Profile Picture
    130 on at
    RE: Uploading attachment to current record in Dynamics F&O with the use of ODataUltility library c#

    I tried to make export with the use of all fields that are mentioned above, but I get this error 

    0407.PNG

    This value is already defined in Vendor Journal, so what should I do 

    7840.Capture2.PNG

  • Dynamics Questions Profile Picture
    130 on at
    RE: Uploading attachment to current record in Dynamics F&O with the use of ODataUltility library c#

    I use VendorPaymentJournalFee type of export, 

     4670.Capture1.PNG

    so all fields with tables appear here after I export them from my environment to Dynamics

    2844.Capture2.PNG

    I need to transfer attachments together with all data (fields, tables) in such a way that, attachments will appear in a new Journal Item, that I exported to Dynamics. I mean here 

    8463.PNG

    For export of my Journal items to dynamics from my environment I use VendorPaymentJournalFee class. Make instance of it, filling and sending to dynamics.

    How I must combine it together with LedgerAttachment instance ( I read that this instance is used for exporting attachments to dynamics). For example : 

    I have filled Journal entity  and I need to make attachment for it, how I can Implement this ?

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,091 on at
    RE: Uploading attachment to current record in Dynamics F&O with the use of ODataUltility library c#

    Hi Dynamics Questions,

    I recommend to create a new entity for your needs (as described in the article) at first (or use existing) and create an example in D365. Then you can export it from D365 and you will get an almost workable package for import. From this package, you will get an idea of what fields and how to fill them.

    Important fields:

    DocumentId - should be unique

    FileContentsFileName - should match filename from Resource folder.

    You can import this package via data package API or recurring API.

    BR, Sergei

  • Martin Dráb Profile Picture
    232,871 Most Valuable Professional on at
    RE: Uploading attachment to current record in Dynamics F&O with the use of ODataUltility library c#
    1. DataAreaId is the ID of an company (legal entity) in F&O. Nevertheless I don't know what method you're talking about and you shouldn't to call any such a method by yourself, as far as I know. It's already handled by DocuRefEntity.insertEntityDataSource().
    2. It depends on the entity you'll create/use. What you'll need at the minimum are mandatory fields of DocuRef table, primary key of the record you're attaching to and the file content.
    3. Unfortunately I don't understand this question. Please try to rephrase it.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,120 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,871 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans