web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Getting the specific record of the line items

(0) ShareShare
ReportReport
Posted on by 3,967

Hi,
I've a requirement wherein Sales Order Card Page when I select the line item, and click on the Custom Action Button.
After selection of the Line Record and Click in the Custom Action Button I want to print a message containing the fields of the selected record.
Kindly suggest for multiple lines as well.

Thanks.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    In your action:

    - Declare a SalesLine variable of Type = Record that points to Sales Line table.

    - In the action code, write:

     CurrPage.SalesLines.PAGE.GETRECORD(SalesLine);

     MESSAGE(SalesLine."No."); //This is the Sales Line selected.

  • Suggested answer
    Divesh Profile Picture
    327 on at

    In addition, if you want to handle multiple line selection then you can use

    CurrPage.SETSELECTIONFILTER(SalesLine);

    and then loop through the record set. An example is available in Standard Page - 22 - "Customer List".

    docs.microsoft.com/.../setselectionfilter-function

  • Olister Rumao Profile Picture
    3,967 on at

    Hi Stefano,

    I would like to select multiple lines in List Part Subform as well. How do I do that?

  • Olister Rumao Profile Picture
    3,967 on at

    Hi Divesh,

    It works for List Page, but not the listpart subform.

    Thanks.

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    For multiple lines, you can do as described by Divesh here.

  • Suggested answer
    Divesh Profile Picture
    327 on at

    Hi

    I have created an action button on the Page - 46 - Sales Order Subform and below is the code

    MultiSelect - OnAction()

    //lSalesLine is a local record variable that points to "Sales Line" table.

    CurrPage.SETSELECTIONFILTER(lSalesLine);

    IF lSalesLine.FINDSET THEN

     REPEAT

       MESSAGE(FORMAT(lSalesLine));

     UNTIL lSalesLine.NEXT = 0;

    In the Sales Order Page, on the lines Fasttab select any single / multiple lines and click this action button MultiSelect. It will loop through and display the message of the selected lines . Hope this helps. Thanks

  • Olister Rumao Profile Picture
    3,967 on at

    Hi Divesh,

    I've tried the following code

    //CurrPage.SalesLines.PAGE.GETRECORD(Rec_SalesLines);

    //MESSAGE(Rec_SalesLines."No.");

    CurrPage.SETSELECTIONFILTER(Rec_SalesLines);

    IF Rec_SalesLines.FINDSET THEN

     REPEAT

       MESSAGE('%1',FORMAT(Rec_SalesLines."No."));

     UNTIL Rec_SalesLines.NEXT=0;

    On Clicking the Action I get an error "TableID does not match."

    I'm trying to select multiple lines on Sales Order page and on Action on the Sales Order Page it should display say the LineNo of the selected lines

  • Verified answer
    Divesh Profile Picture
    327 on at

    Hi

    It seems that you have the action button in the Page - 42 - Sales Order and you want to display the selected lines when you click the action let's name the Action - "Get Selected Lines" to achieve this.

    1.  Create a function GetSelection in the Page - 46 - "Sales Order Subform" 

    GetSelection(VAR pSalesLine : Record "Sales Line")

    CurrPage.SETSELECTIONFILTER(pSalesLine);

    2.  Create a Action "Get Selected Lines" in the Page - 42 - "Sales Order" and  write the below code in the action or a function.

    Get Selected Lines - OnAction()

    //Delcare a local variable lSalesLine --> Record --> Sales Line

    CurrPage.SalesLines.PAGE.GetSelection(lSalesLine);

    IF lSalesLine.FINDSET THEN

     REPEAT

       MESSAGE(FORMAT(lSalesLine));

     UNTIL lSalesLine.NEXT = 0;

    Open the Page - 42 - "Sales Order" and select the lines and then click the Action Get Selected Lines" from the Page - 42 - "Sales Order" it should display the selected lines.

    Hope this is what you need and it works as expected. Thanks

  • Suggested answer
    RockwithNav Profile Picture
    8,600 Super User 2025 Season 2 on at

    Many other members replied with the codes but Instead of this rather I would have asked what you tried and share your code base because this is not something that challenging. You can do it by yourself. :)

  • bharathkarunakaran Profile Picture
    475 on at

    Hi Divesh,

    Its working fine,

    Can you please tell me what is the use of creating a function in sales order subform .

    Regards,

    Bharath K

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.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans