Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Getting the specific record of the line items

Posted on by 3,957

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

  • Verified answer
    CDsilva Profile Picture
    CDsilva 4,184 on at
    RE: Getting the specific record of the line items

    Hi,

    Follow this blog,

    community.dynamics.com/.../how-to-update-the-selected-line-in-the-subform-on-click-of-an-action-button-in-the-mainform-in-nav

    CurrPage.SETSELECTIONFILTER("Sales Lines");

    CurrPage."Sales Lines".PAGE.CallLinesfromCard(SalesLine)

  • Suggested answer
    Divesh Profile Picture
    Divesh 327 on at
    RE: Getting the specific record of the line items

    Hi 

    We can only use the Record in the CurrPage.SETSELECTIONFILTER which is defined in the "Source Table" property of the page. This cannot be directly invoked from the Page - 42 - Sales Order  with a "Sales Line" Record variable, Since the "Source Table" and the reference is different in the page. If you want to use the CurrPage.SETSELECTIONFILTER from the Page - 42 - Sales Order then you can only pass a "Sales Header" record variable, so to get the selected lines from the "Sales Order SubForm" you need to create a function in the SubForm and then invoke that from the "Sales Order" page. Thanks

  • bharathkarunakaran Profile Picture
    bharathkarunakaran 475 on at
    RE: Getting the specific record of the line items

    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

  • Suggested answer
    RockwithNav Profile Picture
    RockwithNav 6,562 on at
    RE: Getting the specific record of the line items

    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. :)

  • Verified answer
    Divesh Profile Picture
    Divesh 327 on at
    RE: Getting the specific record of the line items

    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

  • Olister Rumao Profile Picture
    Olister Rumao 3,957 on at
    RE: Getting the specific record of the line items

    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

  • Suggested answer
    Divesh Profile Picture
    Divesh 327 on at
    RE: Getting the specific record of the line items

    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

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Getting the specific record of the line items

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

  • Olister Rumao Profile Picture
    Olister Rumao 3,957 on at
    RE: Getting the specific record of the line items

    Hi Divesh,

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

    Thanks.

  • Olister Rumao Profile Picture
    Olister Rumao 3,957 on at
    RE: Getting the specific record of the line items

    Hi Stefano,

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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans