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?
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;
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?
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;
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;
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.
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?
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.
Hope this helps.
Thanks.
ZHU
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.
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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,228 Super User 2024 Season 2
Martin Dráb 230,056 Most Valuable Professional
nmaenpaa 101,156