Hello all,
i want to restrict some users to reopen the Document once released
Pls help me to fix the issue in this
tableextension 55010 "User SetupPage(For Job Crate)" extends "User Setup" { fields { field(55010; "Allow ReOpen"; Boolean) { Caption = 'Allow ReOpen'; DataClassification = CustomerContent; } } } pageextension 55011 "User Setup Job Cr" extends "User Setup" { layout { addafter("Register Time") { field("Allow ReOpen"; Rec."Allow ReOpen") { ApplicationArea = All; Caption = 'Allow ReOpen'; } } } }
You can use this code:
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Release Purchase Document", 'OnBeforeReopenPurchaseDoc', '', false, false)]
local procedure OnBeforeReopenPurchaseDoc(var PurchaseHeader: Record "Purchase Header"; PreviewMode: Boolean; var IsHandled: Boolean);
var
UserSetup: Record "User Setup";
begin
If PurchaseHeader."Document Type" = "PurchaseHeader."Document type" :: Order then begin
UserSetup.Get(UserId);
if not UserSetup."Allow ReOpen" then
Error('You Dont have Permission to Reopen');
end;
end;
if i use the same code unit, then how can i mention the Type = Order
Then you use the document type filed:
If "Document type" = "Document Type" :: Order then begin
//your processing
end;
if we want to put this condition only in Purchase order, if we put this it will affect in Purchase invoice also. so how do we mention the scope as order in this code unit
Good to know that your problem is resolved :-)
Thanks Pankaj..its working perfect for both scenarios
Hi
Try with this event that will work for Both "Purchase Order List Page" and "Purchase Order card Page"
Hi..
1. you can add more event in the same Codeunit. you need to add same event for the "Purchase order List Page".
2. if you want to modify "purchase Order List Page" then you need to create separate Page object in same extension.
Note: you can add more objects in same extension.
i have one more doubt. Right now we want to do the same function from purchase order List also
can we add purchase order list also in this code unit. or again we want to create sep page extension for Purcahse order list
Codeunit 55013 "Purchase Order"
{
[EventSubscriber(ObjectType::Page, Page::"Purchase Order", 'OnBeforeActionEvent', 'Reopen', true, true)]
local procedure OnBeforeActionEventWithPO(var Rec: Record "Purchase Header")
var
UserSetup: Record "User Setup";
ErrorLabels: Label 'You Do not have Permission to Reopen.';
begin
UserSetup.Get(UserId);
if not UserSetup."Allow ReOpen" then
Error(ErrorLabels);
end;
}
Good to know that we could help you.
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... 290,522 Super User 2024 Season 2
Martin Dráb 228,441 Most Valuable Professional
nmaenpaa 101,148