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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
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! 
  • Martin Dráb Profile Picture
    241,635 Most Valuable Professional on at
    I believe you're in a wrong forum. The GitHub repository is about integration with D365 Finance and Operations. If it works for you, it must mean that you're indeed using F&O, but this forum is about a completely different product: Dynamics 365 Sales. That's a part of the former Dynamics CRM, while F&O is based on former Dynamics AX.
     
    If you agree, I'll move your question to Dynamics 365 Finance forum, which is one of forums about F&O, and the most active of them.
     
    I admit that the forums are very confusing, but unfortunately I'm a mere moderator and I can't change that.
  • Mar23 Profile Picture
    52 on at
    Thanks for your reply Mr Dráb. And apologies, I was not sure which forum I should be posting to. Sure, go ahead and move it, thanks for letting me know! 
  • Martin Dráb Profile Picture
    241,635 Most Valuable Professional on at
    Moved from the Sales forum.
     
    Can you tell us more about your problem, please? It's not clear why you're unable to get sales agreements.
     
    Is it because you don't know which entity to use? SalesAgreements should be the right (public) name.
     
    Or are you getting an error? If so, is it a compile-time error or a run-time error? What does the message says?
     
    Or does your query executes but it returns no data? If so, try it without any filters and make sure there are some agreements in the environment and company (DataAreaId) which you're connecting to. Using a wrong company is a common mistake.
  • Mar23 Profile Picture
    52 on at
    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. 
  • Martin Dráb Profile Picture
    241,635 Most Valuable Professional on at
    How did you generate the classes? Do you see SalesAgreements in OData metadata (<EntitySet Name="SalesAgreements")?
  • Mar23 Profile Picture
    52 on at
    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
    241,635 Most Valuable Professional on at
    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
    52 on at
    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
    241,635 Most Valuable Professional on at
    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
    52 on at
    Ok so I located the file you mentioned and simply saved it again. Is this what you mean by problems in regenerating files:

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287 Super User 2026 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 232 Most Valuable Professional

#3
Aayush Tiwari Profile Picture

Aayush Tiwari 222

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans