How can i get current record from sales order page.

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.

Answers

  • lubostlubost Posts: 555Member
    Your code should looks like:
    Salesheader.GET(CurrentPage."Document Type",CurrentPage."No.");
    MESSAGE(Salesheader."No.");
  • ManiNavManiNav Posts: 52Member
    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.
  • ManiNavManiNav Posts: 52Member
    Hi lubost/Everyone,

    Please guide me related to above query.{Get the any field value from current form}

    Thanks,
    Mani.
  • Divyesh_Divyesh_ Posts: 2Member
    Kindly try this
    SalesHeader.RESET;
    SalesHeader.COPYFILTERS(Rec);
    CurrPage.SETSELECTIONFILTER(Rec);
    Message('%1',SalesHeader."No.");

    Thanks
    Divyesh Chitte
  • ManiNavManiNav Posts: 52Member
    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.
  • vaprogvaprog Posts: 924Member
    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) using
    MyPage.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.
Sign In or Register to comment.