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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Business Central

(0) ShareShare
ReportReport
Posted on by 208

How to check count of sales order on posted sales shipment for previous month for multiple usersmonthly-ss.png

As shown in the image I want to show count of sales order for previous month in posted sales shipment how can I do in Al code please help 

  • Suggested answer
    IB-29041624-0 Profile Picture
    1,191 Moderator on at

    Is it the user or the sales person you are looking to collect data off?

    You have to loop through the sales person table, filter the shipment on the sales person in the loop and the date span you want to look at and do a saleshipment.count to find the number for each sales person.

  • Dividutt Profile Picture
    208 on at

    I needed to find count of sales order which is in posted sales shipment from all users which is the in User table,

    Also check one month before form today and check how many sales order are posted on each day, how this can be filtered?

    codeunit 50129 " Orders packed by packer"
    {
        procedure orderpacked()
        var
            rec_postedsales: Record "Sales Shipment Header";
            rec_User: Record User;
            user: text;
        begin
            if rec_postedsales.FindSet() then
                repeat
                    if (rec_postedsales."User ID" = 'abc') or (rec_postedsales."User ID" = 'xyz') then
                        Message('%1', rec_postedsales."No.");
                until rec_postedsales.Next() = 0;
        end;
    }
    From this I get detail of only users  i mentioned..
    How it can be different users how we can set that?
    Please do help 
    Thankyou 
  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Hi,

    Can you try below functions? Make sure for the Total posting date count message you manage it better way, I just showing you total counts in the loop.

     procedure orderpacked()
        var
            rec_postedsales: Record "Sales Shipment Header";
            rec_postedsales2: Record "Sales Shipment Header";
            rec_User: Record User;
            user: text;
            TotalUserOrder: Integer;
            XpostingDate: Date;
        begin
            rec_postedsales.Reset();
            rec_postedsales.SetRange("User ID", '<>%1', '');
            rec_postedsales.SetRange("Order No.", '<>%1', '');
            TotalUserOrder := rec_postedsales.Count;
            Message('Total user''s orders:%1', TotalUserOrder);

            rec_postedsales.Reset();
            rec_postedsales.SetCurrentKey("Posting Date");
            rec_postedsales.SetRange("Posting Date", CalcDate('<-1M-1D>', workdate()), WorkDate());
            rec_postedsales.SetRange("Order No.", '<>%1', '');
            if rec_postedsales.FindSet() then
                repeat
                    if XpostingDate <> rec_postedsales."Posting Date" then begin
                        rec_postedsales2.Reset();
                        rec_postedsales2.SetRange("Posting Date", rec_postedsales."Posting Date");
                        Message('Total Orders %1 on Posting Date %2', rec_postedsales2.Count, rec_postedsales2."Posting Date");
                    end;
                    XpostingDate := rec_postedsales."Posting Date";
                until rec_postedsales.Next() < 1;

        end;
  • Dividutt Profile Picture
    208 on at

    Thankyou, I will check it and update.

  • Dividutt Profile Picture
    208 on at

    7384.monthly-ss.png

    Hi, 

    I tried the code but not getting the expected result,

    Is it necessary to setrange on user id as it will be not null?

    And I am also not getting the expected order count.

    I want to check on multiple users and it's posted sales shipment

    And display it's order which is 31 days back from today.

    Rec_postedsales.setrange(Posting date, Today -31,Today)

    How can get sales order count for each day?

    Still stuck with that.

    Is there any other suggestions please do help.

    Thankyou 

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 755 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 413 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 387 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans