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 :
Small and medium business | Business Central, N...
Answered

I want to see the "item" in the "sales order list".

(0) ShareShare
ReportReport
Posted on by 45

Hi,

I want to see the "item" in the "sales order list", what can I do?

My current approach is to add item to the sales order first,

and then add item to the sales order list, but after the addition,

the item field will not automatically bring the correct code.

pastedimage1635128198949v1.png

pastedimage1635128299007v2.png

How should I write my al code? Thanks!

I have the same question (0)
  • Suggested answer
    JAngle Profile Picture
    133 on at

    Based on the assumption it is only ever the 1st item of the sales order? One of these approaches will work for 1 item: https://youtu.be/xXS3txLkm7k

    Or

    https://youtu.be/fXDxAM0ZrvU

  • Verified answer
    Akshay_Panchal Profile Picture
    402 on at

    Hii HUNGXUAN

    If you have to display first line of item code in sales order list page for that you have to add code in Onaftergetrecord and Onopenpage trigger inside sales order list page.If you you have field you can also update using modify function.

    I have shared the code for the same as below

    pageextension 50103 SalesOrderList extends "Sales Order List"
    {
      
        trigger OnAfterGetRecord()
        begin
            updateItemCode()
        end;

        trigger OnOpenPage()
        begin
            updateItemCode();
        end;

        local procedure updateItemCode()
        var
            SalesLine: Record "Sales Line";
        begin
            Clear(ItemCode);
            SalesLine.Reset();
            SalesLine.SetRange("Document Type", Rec."Document Type");
            SalesLine.SetRange("Document No.", Rec."No.");
            if SalesLine.FindFirst() then
                ItemCode := SalesLine."No.";
        end;


        var
            ItemCode: Code[20];
    }
    Verify if this answer fulfill your requirement.
     
     
  • HUNGXUAN Profile Picture
    45 on at

    Thank you very much!!

    But If there are several items in a sales order, how can I display all items instead of only display the first item?

  • HUNGXUAN Profile Picture
    45 on at

    Another question is that I want to filter out the items whose name contains 3 in Sales Orders List, how can I make the item field look like opportunity field, with black words?

    Thank you!!

  • Verified answer
    Akshay_Panchal Profile Picture
    402 on at

    Hi you have to make concatenation for those item codes using

    if SalesLine.Findset then

    repeat

               ItemCode += SalesLine."No."+', ';  //Change datatype of itemcode code to text

    until SalesLine.Next()=0;

  • Suggested answer
    JAngle Profile Picture
    133 on at

    Note that a fact box would have been a good idea too. This way you can have all sales line items displayed

  • Suggested answer
    Akshay_Panchal Profile Picture
    402 on at

    You can use StrPos function for find names which contains the specific substring in your case the substring is 3.

    E.g

    pageextension 50103 SalesOrderList extends "Sales Order List"

    {

       trigger OnAfterGetRecord()

       begin

           updateItemCode()

       end;

       trigger OnOpenPage()

       begin

           updateItemCode();

       end;

       local procedure updateItemCode()

       var

           SalesLine: Record "Sales Line";

       begin

           Clear(ItemCode);

           SalesLine.Reset();

           SalesLine.SetRange("Document Type", Rec."Document Type");

           SalesLine.SetRange("Document No.", Rec."No.");

          repeat

              Pos := StrPos(SalesLine.Description,'3');

              if Pos <> 0 then

                  ItemCode += SalesLine."No."+', ';  //Change datatype of itemcode code to text

          until SalesLine.Next()=0;

       var

           ItemCode: Text;

           Pos : Integer;

    }

    Set field property Style = Strong and StyleExpr=True in page level.

  • HUNGXUAN Profile Picture
    45 on at

    Thank you very much!! I can display all item in Sales Order List and Sales Order Card now.

    There is another question,the item no. field of the Sales Order Card displays black text successfully.

    But the Sales Order List still shows blue words, so that I can’t use the filter function...

    This is my AL Code:

    pageextension 50201 SalesOrderList extends "Sales Order List"

    {

       layout

       {

           addafter("External Document No.")

           {

               field("Item No."; REC."Item No.")

               {

                   ApplicationArea = All;

               }

           }

       }

       trigger OnAfterGetRecord()

       begin

           updateItemCode()

       end;

       trigger OnOpenPage()

       begin

           updateItemCode();

       end;

       local procedure updateItemCode()

       var

           SalesLine: Record "Sales Line";

       begin

           Clear(rec."Item No.");

           SalesLine.Reset();

           SalesLine.SetRange("Document Type", Rec."Document Type");

           SalesLine.SetRange("Document No.", Rec."No.");

           if SalesLine.Findset then

               repeat

                   rec."Item No." += SalesLine."No." + ',';  //Change datatype of itemcode code to text

               until SalesLine.Next() = 0;

       end;

       var

           "Item No.": Text[500];

    }

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,238

#2
YUN ZHU Profile Picture

YUN ZHU 773 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 630

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans