Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Disable item renumbering from item card

Posted on by

We have an issue where a user has accidentally gone into the number series on an existing item, then chose OK which prompts to update the number. We would like to either add a new second dialog that warns that the change will update the number, or see about disabling the OK button. Any guidance on adding another prompt dialog to this?
pastedimage1679503751242v1.png

pastedimage1679503906511v2.png

pastedimage1679503925011v3.png

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,133 Super User 2024 Season 2 on at
    RE: Disable item renumbering from item card

    Yes.

    [EventSubscriber(ObjectType::Table, Database::Item, 'OnBeforeRenameEvent', '', false, false)]

       local procedure OnBeforeRenameEventItem(var Rec: Record Item; var xRec: Record Item; RunTrigger: Boolean)

       begin

           if not Confirm(StrSubstNo('You are about to change this item number to %1. Do you want to continue?', Rec."No.")) then

               Error('');

       end;

    pastedimage1681738404533v1.png

  • kjjson Profile Picture
    kjjson on at
    RE: Disable item renumbering from item card

    Mohana,

    Thank you so much. One last question, do you know if it is possible to capture what the new item would be in the message, for example, "You are about to change this item number to 'NEWITEM'. Do you want to continue?

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,133 Super User 2024 Season 2 on at
    RE: Disable item renumbering from item card

    You have to use OnBeforeRenameEvent as No. is a Primary Key field.

    [EventSubscriber(ObjectType::Table, Database::Item, 'OnBeforeRenameEvent', '', false, false)]

       local procedure OnBeforeRenameEventItem(var Rec: Record Item; var xRec: Record Item; RunTrigger: Boolean)

       begin

           if not Confirm('You are about to change this item number. Do you want to continue?') then

               Error('');

       end;

    pastedimage1681702940607v1.png

  • kjjson Profile Picture
    kjjson on at
    RE: Disable item renumbering from item card

    Shawn, This was very helpful, I am trying to identify how to what to call before the code is executed. Right now, I am just trying to run a message that the change is going to take place if they continue, but it is coming up after the change takes place. Any guidance from here?

    I have tried both:

    EventSubscriberInstance = StaticAutomatic;

       [EventSubscriber(ObjectType::Page, Page::"Item Card", 'OnBeforeValidateEvent', 'No.', true, true)]

       local procedure CheckItemChangeBeforeValidateEvent(var Rec : Record Item)

       begin

          Message('You are about to change this item number');

       end;

    And

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Approvals Mgmt.", 'OnRenameRecordInApprovalRequest', '', true, true)]

    procedure ConfirmChange()

    begin

      MESSAGE('You are about to change this item number');

    end;

  • Suggested answer
    Shawnsauve Profile Picture
    Shawnsauve 1,089 on at
    RE: Disable item renumbering from item card

    Yes, it is possible to add an additional prompt dialog to warn the user before updating the number series on an existing item. One way to achieve this is by customizing the existing code that prompts the user to update the number series.

    You could create a new function that shows an additional prompt dialog, which can be called before the existing code is executed. For example, you could add a confirmation dialog with a message such as "Are you sure you want to update the number series? This action cannot be undone." The function could return a boolean value indicating whether the user confirmed the update or not.

    Once the confirmation dialog function is created, you can modify the existing code to call this function before executing the code that updates the number series. If the user confirms the update, the existing code can be executed as normal. If the user does not confirm the update, the code can exit without making any changes.

    Alternatively, if you are not comfortable modifying the existing code, you could also consider disabling the OK button instead. This can be achieved by adding some JavaScript to the page that the user interacts with. The JavaScript could listen for changes to the number series field, and disable the OK button when a change is detected. You could also add a warning message near the field to notify the user that the OK button is disabled until they have corrected the number series.

  • kjjson Profile Picture
    kjjson on at
    RE: Disable item renumbering from item card

    ZHU, thank you, unfortunately we do need to number things manually. I am still looking for some way to just add a new prompt when the OK button is selected. Is there an easy way to do that?

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,339 Super User 2024 Season 2 on at
    RE: Disable item renumbering from item card

    Hi, If you don't need to enter the number manually, just disable the option below, and an error will be prompted after clicking OK.

    pastedimage1679535198351v1.png

    pastedimage1679535229005v2.png

    pastedimage1679535272418v5.png

    pastedimage1679535256627v4.png

    Hope this helps.

    Thanks.

    ZHU

  • kjjson Profile Picture
    kjjson on at
    RE: Disable item renumbering from item card

    Thanks Inge, even if I could get another pop-up that displays the message that they are about to change the number, or change the prompt that comes up now to include that, it would be better.

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: Disable item renumbering from item card

    You will need customization in code to achieve that. And i am not sure if it is worth it. Remember that if any user by accident have renamed and item you can just rename it back to what you want it to be.

    By doing the customization you talk about you will block that option - and I am not sure I would recommend 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!

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