pageextension 51000 PurchaseInvoice extends "Purchase Invoice"
{
layout
{
modify("Posting Date")
{
Editable = IsEditable;
}
modify("Document Date")
{
Editable = IsEditable;
}
modify("Due Date")
{
Editable = IsEditable;
}
addafter(Status)
{
field("Last Modified At"; Rec.SystemModifiedAt)
{
ApplicationArea = All;
Caption = 'Last Modified At';
Editable = false;
}
field("Last Modified By"; GeneralMgt.GetUserName(Rec.SystemModifiedBy))
{
ApplicationArea = All;
Caption = 'Last Modified By';
Editable = false;
}
}
}
actions
{
modify(SeeFlows)
{
Visible = false;
}
modify(Category_Category8)
{
Caption = 'New caption for Request Approval group';
}
modify(SendApprovalRequest)
{
Visible = false;
}
addafter(SendApprovalRequest)
{
action("Send Approval Request")
{
ApplicationArea = Basic, Suite;
Caption = 'Send A&pproval Request';
Enabled = NOT OpenApprovalEntriesExist AND CanRequestApprovalForFlow;
Image = SendApprovalRequest;
//Promoted = true;
//PromotedCategory = Category8;
//PromotedIsBig = true;
ToolTip = 'Request approval of the document.';
trigger OnAction()
var
ApprovalsMgmt: Codeunit "Approvals Mgmt.";
//PurchH: Record "Purchase Header";
PurchLine: Record "Purchase Line";
PostedInv: Record "Purch. Inv. Header";
begin
If ApprovalsMgmt.CheckPurchaseApprovalPossible(Rec) then Begin
Rec.Reset();
Rec.SetRange("No.", Rec."No.");
Rec.SetRange("Document Type", Rec."Document Type"::Invoice);
If Rec.FindFirst() then begin
PurchLine.Reset();
PurchLine.SetRange("Document Type", PurchLine."Document Type"::Invoice);
PurchLine.SetRange("Document No.", Rec."No.");
PurchLine.Setfilter("Amount Including VAT", '=%1', 0);
If PurchLine.FindFirst() then Begin
Message('The invoice has zero amount');
End
Else Begin
ApprovalsMgmt.OnSendPurchaseDocForApproval(Rec);
End;
End;
//
PostedInv.Reset();
PostedInv.SetRange(PostedInv."Buy-from Vendor No.", Rec."Buy-from Vendor No.");
PostedInv.SetRange(PostedInv."Vendor Invoice No.", Rec."Vendor Invoice No.");
If PostedInv.FindFirst() then begin
Error('Invoice %1 for Vendor %2 already exist and is among the posted invoices. This requires a change in vendor''s invoice number.', Rec."Vendor Invoice No.", Rec."Buy-from Vendor Name");
end;
//
End;
End;
}
}
addafter(SendApprovalRequest_Promoted)
{
actionref(SendApprovalRequestCust_Promoted; "Send Approval Request")
{
}
}
modify(Approvals)
{
Visible = false;
}
addafter(CancelApprovalRequest)
{
action("View Approvals")
{
AccessByPermission = TableData "Approval Entry" = R;
ApplicationArea = Suite;
Caption = 'View Approvals';
Image = Approvals;
//Promoted = true;
//PromotedCategory = Category8;
ToolTip = 'View a list of the records that are waiting to be approved. For example, you can see who requested the record to be approved, when it was sent, and when it is due to be approved.';
trigger OnAction()
var
ApprovalsMgmt: Codeunit "Approvals Mgmt.";
begin
ApprovalsMgmt.OpenApprovalsPurchase(Rec);
end;
}
}
addafter(CancelApprovalRequest_Promoted)
{
actionref(ViewApprovals_Promoted; "View Approvals")
{
}
}
}
Trigger OnNewRecord(BelowxRec: Boolean)
begin
FieldNotEditable();
end;
//
trigger OnAfterGetCurrRecord()
begin
SetControlAppearance;
CurrPage.IncomingDocAttachFactBox.PAGE.LoadDataFromRecord(Rec);
CurrPage.ApprovalFactBox.PAGE.UpdateApprovalEntriesFromSourceRecord(Rec.RecordId);
ShowWorkflowStatus := CurrPage.WorkflowStatus.PAGE.SetFilterOnWorkflowRecord(Rec.RecordId);
//StatusStyleTxt := GetStatusStyleText();
FieldNotEditable();
end;
//
trigger OnOpenPage()
var
myInt: Integer;
begin
FieldNotEditable();
end;
//
local procedure SetControlAppearance()
var
ApprovalsMgmt: Codeunit "Approvals Mgmt.";
WorkflowWebhookMgt: Codeunit "Workflow Webhook Management";
begin
OpenApprovalEntriesExistForCurrUser := ApprovalsMgmt.HasOpenApprovalEntriesForCurrentUser(Rec.RecordId);
OpenApprovalEntriesExist := ApprovalsMgmt.HasOpenApprovalEntries(Rec.RecordId);
CanCancelApprovalForRecord := ApprovalsMgmt.CanCancelApprovalForRecord(Rec.RecordId);
WorkflowWebhookMgt.GetCanRequestAndCanCancel(Rec.RecordId, CanRequestApprovalForFlow, CanCancelApprovalForFlow);
OnAfterSetControlAppearance();
end;
//
var
OpenApprovalEntriesExistForCurrUser: Boolean;
OpenApprovalEntriesExist: Boolean;
ShowWorkflowStatus: Boolean;
CanCancelApprovalForRecord: Boolean;
CanRequestApprovalForFlow: Boolean;
CanCancelApprovalForFlow: Boolean;
IsEditable: Boolean;
StatusStyleTxt: Text;
GeneralMgt: Codeunit "General Management";
[IntegrationEvent(true, false)]
local procedure OnAfterSetControlAppearance()
begin
end;
procedure FieldNotEditable()
var
PurchInv: Record "Purchase Header";
UserSetUp: Record "User Setup";
begin
IsEditable := true;
UserSetUp.Reset();
UserSetUp.SetRange("User ID", UserId);
UserSetUp.SetRange("Field Not Editable", true);
If UserSetUp.FindFirst() then Begin
PurchInv.Reset();
PurchInv.SetRange("No.", Rec."No.");
If PurchInv.FindFirst() then begin
If (PurchInv."Posting Date" <> 0D) or (PurchInv."Document Date" <> 0D) or (PurchInv."Due Date" <> 0D) then
IsEditable := false;
end;
End;
end;
}
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,188 Super User 2024 Season 2
Martin Dráb 230,030 Most Valuable Professional
nmaenpaa 101,156