How can i get current record from sales order page.

ManiNav
Member Posts: 120
Hi Everyone,
[In Nav 2009]
I would like to catch current record from sales order Page. I wrote codeunit and I put this in custom button in sales order page.I am able to call that codeunit after clicking the custom button, but I am not able to get current Field value('No' field from Header).
Below is my codeunit, please guide me to get the current record.
Codeunit:[var: CurrentPage-Sales Order]
Salesheader.RESET;
Salesheader.SETCURRENTKEY("Document Type","No.");
Salesheader.SETRANGE("Document Type",Salesheader."Document Type"::Order);
CurrentPage.SETTABLEVIEW(Salesheader);
MESSAGE(Salesheader."No.");
Thanks,
Mani.
[In Nav 2009]
I would like to catch current record from sales order Page. I wrote codeunit and I put this in custom button in sales order page.I am able to call that codeunit after clicking the custom button, but I am not able to get current Field value('No' field from Header).
Below is my codeunit, please guide me to get the current record.
Codeunit:[var: CurrentPage-Sales Order]
Salesheader.RESET;
Salesheader.SETCURRENTKEY("Document Type","No.");
Salesheader.SETRANGE("Document Type",Salesheader."Document Type"::Order);
CurrentPage.SETTABLEVIEW(Salesheader);
MESSAGE(Salesheader."No.");
Thanks,
Mani.
0
Answers
-
Your code should looks like:
Salesheader.GET(CurrentPage."Document Type",CurrentPage."No.");
MESSAGE(Salesheader."No.");0 -
Hi lubost,
Thanks for reply,
How "CurrentPage" will take Field value(Document Type and No.),CurrentPage(SALES ORDER- PAGE) is page.From current "Sales order" page only i want to catch any field.
Please check and guide me further.
Thanks,
Mani.0 -
Hi lubost/Everyone,
Please guide me related to above query.{Get the any field value from current form}
Thanks,
Mani.0 -
Kindly try this
SalesHeader.RESET;
SalesHeader.COPYFILTERS(Rec);
CurrPage.SETSELECTIONFILTER(Rec);
Message('%1',SalesHeader."No.");
Thanks
Divyesh Chitte0 -
Hi Divyesh_ ,
Thanks for the reply. As you suggest to use SETSELECTIONFILTER for the page,I am not able to add that function.{And, I am using: Rec-SalesHeader}.
Please check once and guide me further.
Thanks,
Mani.0 -
You can get the current record only from within the page.
Only if you called the page yourself, using a variable of type page, you may get the current record after the page has been closed (that is, the record that last was current) usingMyPage.GETRECORD(MyRec)
On a Page with a subpage you can use the same kind of code using the subpage control.
SETSELECTIONFILTER sets a filter, and can only be used from within the page. It is only able to find the current record if no record is selected or exactly one record is selected. If you are within the page, Rec is your current record at all times.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions