Hi All,
I am having a problem on calling a Navision code unit. The senario:
I have a button called 'POST". My objective is that when user will click the post button his selected (selction of a Sales Order Header Id is done) of an Order or Invoice, will get posted.
I want to call the codeunit 80/81 from my code. How shall I call code unit 80 from my code ?
Thanks in advance. Please help.
Arindam
0
Answers
In code
SalesPost.RUN(SalesHeader);
Other way around, in menu item define runobject has Codeunit Sales-Post
Freelance Dynamics AX
Blog : http://axnmaia.wordpress.com/
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Now I want to know to post a Sales Order what code unit shall I use ? Also to post an Invoice what code unit shall I use ?
Once again thanks in advance.
They all use the same codeunit as they are all the same table!
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com
Don't get confused for the Document Type....as David said...its the same SALESHEADER.
For any queries you can also visit my blog site: http://msnavarena.blogspot.com/
Now if i just want to post only 2 Order then how come I make the code unit understand that it should perform the posting task for these 2 Orders only ? say I marked 2 of the Orders.
I hope I am able to clear my point.
Arindam
If you want to automate anything in NAV that is available in the standard database, you turn on the debugger and see how it's done in standard NAV. Learn from that and apply that knowledge to your project.
So in this instance, you want to automate posting an invoice in a button. What you do is create an invoice, turn on the debugger, and post it. See what happens under the hood and program it in your button.
RIS Plus, LLC
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Looping is happening perfectly. My code is :
Repeat
if mark then
CODEUNIT.RUN(CODEUNIT::"Sales-Post",recSalesOrderHead);
until (..)
recSalesOrderHead is the record object for Sales Header.
My problem is whenever i am passing this it is taking the fisrt record which is 'offer' in this case. I want to pass all the marked order to be posted.
Please help
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
recSalesOrderHead.SETRANGE(recSalesOrderHead."No.","No.");
CODEUNIT.RUN(CODEUNIT::"Sales-Post (Yes/No)",recSalesOrderHead);
Here I am trying to set the sales order number i want to pass to the code unit.
But when I am nevigating the code unit in debug mode it is showing that no record is selected at the code unit level and throwing an error.
If I can pass my desired Sales Header "No." to the code unit then I think it will solve my problem. But I am not able to do that.
Please advice.
I was going through the posts..well what Kine said is right...LOOP will do. Try using find('-') or FINDFIRST after the setrange that you have applied.
For any queries you can also visit my blog site: http://msnavarena.blogspot.com/
It solved. I use -
recSalesOrderHead.SETRANGE(recSalesOrderHead."No.","No.");
recSalesOrderHead.FIND('-');
CODEUNIT.RUN(CODEUNIT::"Sales-Post",recSalesOrderHead);
It is now passing the current record to the code unit.
Thank you guys. You solved this problem.
Regards,
Arindam