Is it possible to call sales order page release action form codeunit?
vinceliu666
Member Posts: 51
Hi All:
I want to call sales order page release action through web service from c# app.Is it possible to call sales order page release action form codeunit or page ? Our NAV version is 2016
I want to call sales order page release action through web service from c# app.Is it possible to call sales order page release action form codeunit or page ? Our NAV version is 2016
0
Best Answers
-
If you can still make changes to the Sales Order page (where the Release button is located), you should still be able to achieve this (assuming you don't want to move the release code to some more centralized location)
- Move all the code from Release button into a global function (could be on the same page) and have the button call the function
- In your codeunit, get the Sales Header, create a variable for the page, set the record to it and then run the function
Basically, the idea is that you would turnRelease - OnAction() //trigger ReleaseSalesDoc.PerformManualRelease(Rec); #CustomCode
intoRelease - OnAction() //trigger PagePerformRelease; //############## PagePerformRelease() //global function ReleaseSalesDoc.PerformManualRelease(Rec); #CustomCode
And then in your codeunit you do:SalesHeader.GET(DocType,DocNo) PageSalesOrder.SETRECORD(SalesHeader); PageSalesOrder.PagePerformRelease;
Of course, if you're making such changes, it'd be better to take the "PagePerformRelease" function and put it into some codeunit, then you wouldn't need this workaround.5 -
>But sometimes we will program some code in "Release Action" on the Sales Order page for validate or do something
Well, don't do this. Put them into a function and make the action call that function. Even putting that function on the Page solves it, but it is not ideal.
Think like this: suppose you take over support of this customer from another NAV partner. You run the Release codeunit by code and you don't even know that there is custom code on the page. So try to put it into a place where it gets noticed. Put the code into the release codeunit. Put the code into a custom object and just call the function from the release codeunit -> easier upgrade. If on a newer version, see if the release codeunit has events, and implement them. That is the best upgrade-friendly. Just putting code right into that Page Action is not the kind of thing a professional consultant does.
The reason you cannot call actions by C/AL is entirely intentional, it is to discourage you to put anything but function calls into them.5
Answers
-
Yes, there's codeunit 414 "Release Sales Document" that has a function PerformManualRelease (takes Sales Header as parameter).0
-
Hi ShaiHulud

Thanks for your reply. I could call codeunit 414 to release the Sales Order Document. But sometimes we will program some code in "Release Action" on the Sales Order page for validate or do something between user press the Release action and the action to call codeunit 414. Therefore, if i call the codeunit 414 directly. Those code in "Release Action" which before the action to call codeunit414 will not be access.
I think the best way is to call Sales Order Page "Release Action" directly. But it seems not possible.
Do you have any ideal to do this?
0 -
If you can still make changes to the Sales Order page (where the Release button is located), you should still be able to achieve this (assuming you don't want to move the release code to some more centralized location)
- Move all the code from Release button into a global function (could be on the same page) and have the button call the function
- In your codeunit, get the Sales Header, create a variable for the page, set the record to it and then run the function
Basically, the idea is that you would turnRelease - OnAction() //trigger ReleaseSalesDoc.PerformManualRelease(Rec); #CustomCode
intoRelease - OnAction() //trigger PagePerformRelease; //############## PagePerformRelease() //global function ReleaseSalesDoc.PerformManualRelease(Rec); #CustomCode
And then in your codeunit you do:SalesHeader.GET(DocType,DocNo) PageSalesOrder.SETRECORD(SalesHeader); PageSalesOrder.PagePerformRelease;
Of course, if you're making such changes, it'd be better to take the "PagePerformRelease" function and put it into some codeunit, then you wouldn't need this workaround.5 -
>But sometimes we will program some code in "Release Action" on the Sales Order page for validate or do something
Well, don't do this. Put them into a function and make the action call that function. Even putting that function on the Page solves it, but it is not ideal.
Think like this: suppose you take over support of this customer from another NAV partner. You run the Release codeunit by code and you don't even know that there is custom code on the page. So try to put it into a place where it gets noticed. Put the code into the release codeunit. Put the code into a custom object and just call the function from the release codeunit -> easier upgrade. If on a newer version, see if the release codeunit has events, and implement them. That is the best upgrade-friendly. Just putting code right into that Page Action is not the kind of thing a professional consultant does.
The reason you cannot call actions by C/AL is entirely intentional, it is to discourage you to put anything but function calls into them.5 -
Hi Miklos_Hollender:
Thanks for your reply.Your suggestion is very important key thinking point.Both of you are expert in NAV ERP.I will follow your suggestion to make sure programming team members work smoothly.
Thanks both of you again.0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
