Skip to main content

Notifications

Announcements

No record found.

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

Block sales order creation

(1) ShareShare
ReportReport
Posted on by 105

Hi dears,

I know during creation of SO, when you enter an item quantity in Sales order line you get notification if that quantity is more than available quantity in the store, you can proceed but during posting you get stucked.

Now I was finding the way to block/stop the process when the quantity entered is bigger than available quantity, just when typing in quantity block process for that item

Thank you 

  • Maro9595 Profile Picture
    Maro9595 105 on at
    RE: Block sales order creation

    Thank you,

    Correct

  • Verified answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,194 Super User 2024 Season 2 on at
    RE: Block sales order creation

    You can try with the below code but it will show error like below.

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Item-Check Avail.", 'OnBeforeCreateAndSendNotification', '', false, false)]
        local procedure OnBeforeCreateAndSendNotification(ItemNo: Code[20]; UnitOfMeasureCode: Code[20]; InventoryQty: Decimal; GrossReq: Decimal; ReservedReq: Decimal; SchedRcpt: Decimal; ReservedRcpt: Decimal; CurrentQuantity: Decimal; CurrentReservedQty: Decimal; TotalQuantity: Decimal; EarliestAvailDate: Date; RecordId: RecordId; LocationCode: Code[10]; ContextInfo: Dictionary of [Text, Text]; var Rollback: Boolean; var IsHandled: Boolean);
        var
            ItemCheckAvail: Codeunit "Item-Check Avail.";
            NotificationLifecycleMgt: Codeunit "Notification Lifecycle Mgt.";
            ItemAvailabilityCheck: Page "Item Availability Check";
            AvailabilityCheckNotification: Notification;
            NotificationMsg: Label 'The available inventory for item %1 is lower than the entered quantity at this location.', Comment = '%1=Item No.';
            DetailsTxt: Label 'Show details';
            DontShowAgainTxt: Label 'Don''t show again';
        begin
            AvailabilityCheckNotification.Id(CreateGuid());
            AvailabilityCheckNotification.Message(StrSubstNo(NotificationMsg, ItemNo));
            AvailabilityCheckNotification.Scope(NOTIFICATIONSCOPE::LocalScope);
            AvailabilityCheckNotification.AddAction(DetailsTxt, CODEUNIT::"Item-Check Avail.", 'ShowNotificationDetails');
            AvailabilityCheckNotification.AddAction(DontShowAgainTxt, CODEUNIT::"Item-Check Avail.", 'DeactivateNotification');
            ItemAvailabilityCheck.PopulateDataOnNotification(AvailabilityCheckNotification, ItemNo, UnitOfMeasureCode,
              InventoryQty, GrossReq, ReservedReq, SchedRcpt, ReservedRcpt, CurrentQuantity, CurrentReservedQty,
              TotalQuantity, EarliestAvailDate, LocationCode);
            NotificationLifecycleMgt.SendNotificationWithAdditionalContext(
              AvailabilityCheckNotification, RecordId, ItemCheckAvail.GetItemAvailabilityNotificationId());
            Rollback := true;
            IsHandled := true;
        end;

    pastedimage1673584336648v1.png

  • Verified answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Block sales order creation

    Hi,

    You need to customize the solution like when you enter the Item on Sales Line, call a OnAfterValidate trigger of that Item and check if you have enough quantity available and then allow otherwise block with error.

    Thanks

    Nitin

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 74,115 Super User 2024 Season 2 on at
    RE: Block sales order creation

    Hi, as far as I know this needs to be customized and by default it won't block when you type the quantity.

    Hope this helps.

    Thanks.

    ZHU

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: Block sales order creation

    So you don't have any more questions for your case?

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans