Skip to main content

Notifications

Announcements

No record found.

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

Rename Group on a native page

(1) ShareShare
ReportReport
Posted on by
Hi all,
How do I rename Request Approval on Purchase Invoice Card?
  • RomRyan Profile Picture
    RomRyan on at
    Rename Group on a native page
    Mohana,
    I am using version 19 on prem
  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,194 Super User 2024 Season 2 on at
    Rename Group on a native page
    Yes, which version of BC are you using?
  • RomRyan Profile Picture
    RomRyan on at
    Rename Group on a native page
    Mohana,
     
    Thanks so much for your time.
    I am getting this error
     
    'Pages with ActionRef syntax' is not available in runtime version '8.0'. The supported runtime versions are: '10.0' or greater.ALAL0666
     
    I suspect it's cause am on run rime 8.0
  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,194 Super User 2024 Season 2 on at
    Rename Group on a native page
    Please try with this
     
    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;
    }
     
  • RomRyan Profile Picture
    RomRyan on at
    Rename Group on a native page
    Mohana,
    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("Request Approval")
            {       
            
                Caption = 'Approval';           
                      
            }  
            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;
                }
                
            }
            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;
                    }
            }

        }
        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;
    }
     
  • Mohana Yadav Profile Picture
    Mohana Yadav 59,194 Super User 2024 Season 2 on at
    Rename Group on a native page
    Can you share the whole code of the purchase invoice pageextension?
  • RomRyan Profile Picture
    RomRyan on at
    Rename Group on a native page
    Mohana,
     
    There are other actions in the group and have 
     
    Promoted = true;
                    PromotedCategory = Category8;
                    PromotedIsBig = true;
     
    i.e. Send Approval Request and Cancel Approval Request
    But they need to under Request Approval (group) which I want to rename it to Approvals but still maintain Send Approval Request and Cancel Approval Request under Request Approval without changing any position.
     
    How can I achieve this?
     
     
     
     
  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,194 Super User 2024 Season 2 on at
    Rename Group on a native page
    Do you have any other actions on the pageextension which are using Promoted or PromotedCategory etc.?
    Please change them to reference the Promoted parts in the base Purchase Invoice page.
  • RomRyan Profile Picture
    RomRyan on at
    Rename Group on a native page
    Mohana,
     
    If I use
           modify(Category_Category8)
            {
                Caption = 'New caption for Request Approval group';
            }
     
    I get an error
     
    The Group 'Category_Category8' cannot be referenced in PageExtension 'PurchaseInvoice' because 'Category_Category8' is defined in the promoted part of the action part while 'PurchaseInvoice' uses promoted action properties.ALAL0737
    Group Category_Category8
     
    If I use
    modify("Request Approval")
            {       
            
                Caption = 'Approval';           
                      
            }
    The caption is not changing to Approval.
  • Suggested answer
    Shivi1307 Profile Picture
    Shivi1307 17 on at
    Rename Group on a native page
    Caption is the way to rename anything on the page.

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