Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

Getting a list of Sales Agreements

(0) ShareShare
ReportReport
Posted on by 52
Hi everyone! 
 
I have been using this sample logic app template - https://github.com/microsoft/Dynamics-AX-Integration such that I may be able to get elements from Dynamics 365 programmatically.
 
I was able to get a list of Sales Orders, Customers, etc. I used similar code to that in the QueryExamples.cs. For instance, to get a list of sales orders, I used:
context.SalesOrderHeaders.Where(x => x.InvoiceCustomerAccountNumber == /12345/); 
However, I am unable to get a list of Sales Agreements. 
 
Has anyone every done this before or has any suggestions on how this can be achieved? 
 
Thanks in advance! 
  • Verified answer
    Mar23 Profile Picture
    Mar23 52 on at
    Getting a list of Sales Agreements
    Hi Mr Dráb,
     
    Just to let you know that I managed to solve the issue! 
     
    I downloaded the Connected Services extension on VS and regenerated the classes required. I made sure to select the SalesAgreements schema. 
     
    Thanks a lot for your help - I was only able to solve this after understanding your explanation of how these classes were created. 
  • Mar23 Profile Picture
    Mar23 52 on at
    Getting a list of Sales Agreements
    I redownloaded the files but it did not seem to help unfortunately. I read on Stack Overflow that I should download the Visual Studio Extension ODataConnected Service which should get those files, but I ended up with a bunch more errors:

     
    Perhaps I am supposed to follow steps in the following article: https://learn.microsoft.com/en-us/odata/connectedservice/getting-started ? 
     
    From my understanding, this is how the original classes were created. If I were to create classes myself so that I may access the Sales Agreements, is this what I need to do? And if it is, how will I know the the metadata endpoint of the service to use? 
     
    Thanks in advance! 
  • Martin Dráb Profile Picture
    Martin Dráb 230,848 Most Valuable Professional on at
    Getting a list of Sales Agreements
    A missing file doesn't sound like to cryptic error. I'll assume that the error message is right and that the file doesn't exist. I wouldn't spend any time on investigation and I would simply copy files from Packages to the folder mentioned in the error message. I would investigate the problem only if this didn't help.
  • Mar23 Profile Picture
    Mar23 52 on at
    Getting a list of Sales Agreements
    Ok so I located the file you mentioned and simply saved it again. Is this what you mean by problems in regenerating files:
  • Martin Dráb Profile Picture
    Martin Dráb 230,848 Most Valuable Professional on at
    Getting a list of Sales Agreements
    I'm sorry, I forgot to mention the file. It's in ODataClient.tt.
     
    .tt files are T4 templates for generating text files, such as (as in this case) files with source code.
  • Mar23 Profile Picture
    Mar23 52 on at
    Getting a list of Sales Agreements
    Hi Mr Dráb, thank you for your reply. I am new to using OData services. 
     
    What do you mean by updating the MetadataDocumentUri exactly? 
     
    This is my ODataUtility, exactly like that from github: 

    Do I need to create custom entities myself following this tutorial: https://learn.microsoft.com/en-us/odata/client/code-generation-tool ? 
  • Martin Dráb Profile Picture
    Martin Dráb 230,848 Most Valuable Professional on at
    Getting a list of Sales Agreements
    Well, you aren't using data entities directly. You're using classes (such as SalesOrderHeaders) generated from data entities exposed through OData service.
     
    But you didn't generate classes for entities in your environment. You're using code that someone generated six years ago (and saved on GitHub). You're missing all custom entities and also all entities added to F&O in past six years. It may be the case of sales agreements too.
     
    You need to go ODataUtility project and update MetadataDocumentUri. After saving the file, the classes should be re-generated (unless there is a problem, which is unfortunately quite common).
  • Mar23 Profile Picture
    Mar23 52 on at
    Getting a list of Sales Agreements
    I'm not sure what you mean by "How did you generate the classes?". I am using a sample template in ODataConsoleApplication from the github repository. There is not definition for SalesAgreements in Resources. 
  • Martin Dráb Profile Picture
    Martin Dráb 230,848 Most Valuable Professional on at
    Getting a list of Sales Agreements
    How did you generate the classes? Do you see SalesAgreements in OData metadata (<EntitySet Name="SalesAgreements")?
  • Mar23 Profile Picture
    Mar23 52 on at
    Getting a list of Sales Agreements
    It seems that SalesAgreements does not exist in Resources. In fact, that is the error that I am getting - Resources does not contain a definition for SalesAgreements and no accessible extension method SalesAgreements accepting a first argument of type Resource would be found. This is when attempting : 
    context.SalesAgreements;
     
    I did go over the code in Resources and there does not seem to be a definition. So I am not sure how this information can be retrieved. 

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,979 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,848 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans