Skip to main content

Notifications

Small and medium business | Business Central, N...
Answered

Business Central

Posted on by 200

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 

  • Dividutt Profile Picture
    Dividutt 200 on at
    RE: Business Central

    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 

  • Dividutt Profile Picture
    Dividutt 200 on at
    RE: Business Central

    Thankyou, I will check it and update.

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Business Central

    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
    Dividutt 200 on at
    RE: Business Central

    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
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: Business Central

    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.

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,056 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans