Skip to main content

Notifications

Announcements

No record found.

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

Creating a Release Order from agreement via OData

(1) ShareShare
ReportReport
Posted on by 52
Hi everyone! 
I am attempting to create a release order programmatically. Typically using the D365 portal, this would be done by finding a sales agreement, and click Release order from the New tab: 
 
My environment on Visual Studio is setup in a similar manner as the Github sample ODataConsoleApplication: https://github.com/microsoft/Dynamics-AX-Integration/tree/master/ServiceSamples 
 
I generated the latest entities made available using the Connected Services extension and have data entities such as SalesAgreements now available. However, I do not have one for release orders - it seems like it is not a data entity made available. Thus I cannot use it in the same way SalesOrderHeader can be used to create a sales order collection.
 
Therefore, how can I create a release order programmatically please? 
 
Thanks in advance!
  • nurlin_aberra Profile Picture
    nurlin_aberra 2 on at
    Creating a Release Order from agreement via OData
    This is just the custom service seudo code , there is a function to release from sales agremment to sals order , this is creating the SO directly and is not correct code.
    you can read about the rest in ms learn or https://dynamics365musings.com/create-a-custom-service-in-d365/ (good blog)

    class CreateSalesOrderService
    {
    [SysEntryPointAttribute]
    public static CreateSalesOrderContract CreateSalesOrderFromAgreement(CreateSalesOrderContract _contract)
    {
    SalesAgreement salesAgreement;

    salesAgreement = SalesAgreement::find(_contract.salesAgreementId);

    if (salesAgreement)
    {
    _contract.salesOrder.initValue();
    _contract.salesOrder.SalesId =  // get from num seq
    _contract.salesOrder.CustAccount = salesAgreement.CustAccount;
    _contract.salesOrder.CurrencyCode = salesAgreement.CurrencyCode;
    _contract.salesOrder.SalesType = SalesType::Sales;
    _contract.salesOrder.initFromAgreement(salesAgreement);

    ttsBegin;
    _contract.salesOrder.insert();
    ttsCommit;

    return _contract;
    }
    else
    {
    throw error("Sales agreement not found.");
    }
    }
    }
     
     
     
     
     
    contract class
    [DataContractAttribute]
    class CreateSalesOrderContract
    {
    [DataMemberAttribute("SalesAgreementId")]
    public SalesAgreementId salesAgreementId;

    [DataMemberAttribute("SalesOrder")]
    public CustVendSalesPurchOrderJour salesOrder;
    }
  • Mar23 Profile Picture
    Mar23 52 on at
    Creating a Release Order from agreement via OData
    Just to let you know that I had updated the previous reply right before you replied, and added different questions. 
     
    We have a functional consultant but they are not familiar with the backend aspect of F&O. 

    We are interested in the backend aspect, not UI or frontend. 
  • Martin Dráb Profile Picture
    Martin Dráb 230,540 Most Valuable Professional on at
    Creating a Release Order from agreement via OData
    No, it's not the same thing. Releasing gives you dialog (which you talked about before), where you define parameters including which lines should be created. As far as I know, you won't get such a dialog when creating a sales order directly and you need to create lines by yourself.
     
    Don't you have any functional consultant and no F&O developer in your team? They should help you with these things.
     
    While simple data entity extensions may be trivial, this isn't such a case and it may be challenging if you're new to F&O development. First of all, you should familiarize with data entities and their development in general. See documentation pages in this section of documentation. Then you should learn a bit about extensions in general (such as Chain of Command) and extensions of data entities. Than you can start designing a technical solution for your business requirements.
     
    For example, you could outer-join AgreementHeader to SalesTable (via MatchingAgreement) in SalesOrderHeaderV2Entity and implement code for DataEntityDatabaseOperation::Insert to execute your logic. You would use editSalesAgreementId() as the starting point and change it to work in this scenario (e.g. there can't be Box::yesNo() for user input) and to meet your particular requirements.
     
  • Mar23 Profile Picture
    Mar23 52 on at
    Creating a Release Order from agreement via OData
    I have been looking at the GUI, releasing sales order from the portal to get an understanding of how it works. To clarify, I do not want to create an UI aspects, I just want to have functionality to release a sales order from the backend. 
     
    I am still not sure how the best way to approach it would be; whether it should just be linked using a Sales Agreement ID and manually getting information from the sales agreement to the sales order, or if there is a way that this can be done automatically when releasing a sales order. I don't know what sort of functionality is made available and I cannot seem to find documentation. What do you suggest? 
     
    Moreover, when you say "You'll find that SalesCreateOrder form has editSalesAgreementId() method for this purpose, which calls - most inportantly - SalesTable.initFromSalesAgreementHeader(). This logic doesn't seem to be called by any data entity, but you can change that, because entities can be extended."  Do I have access the these methods (editSalesAgreementId() and SalesTable.initFromSalesAgreementHeader()? If so, where can I find these? And how would these be used? Should a new class for a ReleaseOrder be created which extends from the SalesOrderHeader and adds additional properties, such as the SalesAgreementId? But then, how can this class be used to save a released sales order if the sales orders do not have these parameters? 

    Thanks in advance.
     
  • Martin Dráb Profile Picture
    Martin Dráb 230,540 Most Valuable Professional on at
    Creating a Release Order from agreement via OData
    Last time you said you want to "implement the dialog for parameters" programmatically, but now it sounds you don't want it at all, because you're fine with mere agreement ID and you don't need any other parameters at all. Is it the case? If so, that makes things easier, because we can completely forget your previous requirement about the dialog.
     
    As I mentioned, you should check the process in GUI, before you try to automate it. Now it seems you want the process where you specify an agreement ID when creating a sales order, instead of the process of releasing an order from an agreement and specifying in the dialog how the order should be created.
     
    If that's the case, a reasonable approach is looking at how the logic works. You'll find that SalesCreateOrder form has editSalesAgreementId() method for this purpose, which calls - most inportantly - SalesTable.initFromSalesAgreementHeader(). This logic doesn't seem to be called by any data entity, but you can change that, because entities can be extended.
  • Mar23 Profile Picture
    Mar23 52 on at
    Creating a Release Order from agreement via OData
    At this stage, I am just looking of replicating the release process to create a sales order from the agreement. In that way, we would automatically have the data retrieved from the sales agreement and be used for the sales order. And we would also have checks which would say that there are conflicts between the input data and the data from the sales agreement. 

    Again, I am not sure what the best way to implement this would be. Since there is no ReleaseOrderHeader just like the SalesOrderHeader, at least, that I am aware of. And there is also no parameter for sales agreement ID in SalesOrderHeader.

  • Martin Dráb Profile Picture
    Martin Dráb 230,540 Most Valuable Professional on at
    Creating a Release Order from agreement via OData
    Well, when I said you should test the process in GUI, I didn't meant that you should forget the process  and focus on GUI only.
     
    Will "implement the below screenshot programmatically" create a sales order from an agreement? Not at all. This is just the step in the process where you're configuring parameters; it's not the creation itself. That happens when you confirm the dialog.
     
    It's possible - but by no mean certain - that you'll decide that you want an external system to populate exactly the same set of parameters, and you'll design input parameters of your integration accordingly. It depends on a lot on business requirements, e.g. what information is available in the other system and which parts should be done automatically instead of having to be specified explicitly.
     
     
  • Mar23 Profile Picture
    Mar23 52 on at
    Creating a Release Order from agreement via OData
    Thanks for the steps you provided. 
     
    So if I wanted to implement the below screenshot programmatically, with the same checks (e.g. not exceeding quantity), what would be the best way to do it in your opinion?
  • Martin Dráb Profile Picture
    Martin Dráb 230,540 Most Valuable Professional on at
    Creating a Release Order from agreement via OData
    Well, maybe you should create a new thread about the process inside F&O, discuss it with functional consultants and then return back and talk about integration via OData here.
     
    Anyway, according to what I see in code, it seems to me that you can link an agreement (in SalesTable form) by using opening Update line menu above the line grid, locating Sales agreement group and clicking Create link.
  • Mar23 Profile Picture
    Mar23 52 on at
    Creating a Release Order from agreement via OData
    Once again, thanks for your reply Mr Dráb.
     
     
    However, I cannot find how to link a sales order with a sales agreement when creating a sales order directly. I added the customer requisition and reference numbers, but when attempting to enter quantities larger than those specified in the agreement, I am not getting any errors. So I am suspecting that the agreement was not linked after all. 

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,861 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,540 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans