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:
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?
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.
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.
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áb230,540Most Valuable Professional
on at
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.
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áb230,540Most Valuable Professional
on at
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.
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áb230,540Most Valuable Professional
on at
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.
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.