web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Custom Workflow for Custom Page

(0) ShareShare
ReportReport
Posted on by 85

Hello Experts, 

I have a question regarding Workflow approval requests created by writing to Requests To Approve page /Approval entry table. Or if there is something wrong with my initial approach.

I have a custom page, where I define some record(s). On the page I have this action assigned to a button. 

 action(RequestApproval)
            {
                ApplicationArea = All;
                trigger OnAction()
                begin
                    CurrPage.SetSelectionFilter(Rec);
                    if Rec.FindSet()
                    then begin
                        repeat
                            //RequestsToApprove."Document No." := rec.DocNo;
                            //RequestsToApprove."Document Type" := RequestsToApprove."Document Type"::Order;
                            RequestsToApprove."Table ID" := 50110;
                            RequestsToApprove."Approver ID" := 'APPROVALUSER';
                            RequestsToApprove.Status := RequestsToApprove.Status::Open;
                            RequestsToApprove.Comment := false;
                            RequestsToApprove.Amount := 0;
                            RequestsToApprove."Approval Type" := RequestsToApprove."Approval Type"::"Sales Pers./Purchaser";
                            RequestsToApprove."Limit Type" := RequestsToApprove."Limit Type"::"Approval Limits";
                            RequestsToApprove."Due Date" := Rec.DueDate;
                            RequestsToApprove."Approval Code" := 'MS-SOAPW-01';
                            RequestsToApprove."Sequence No." := 1;
                            RequestsToApprove."Sender ID" := 'NAVADMIN';
                            RequestsToApprove."Salespers./Purch. Code" := 'AH';
                            RequestsToApprove."Date-Time Sent for Approval" := CurrentDateTime();
                            RequestsToApprove."Last Date-Time Modified" := CurrentDateTime();
                            RequestsToApprove."Last Modified By User ID" := 'NAVADMIN';
                            RequestsToApprove.Amount := 5000;
                            RequestsToApprove."Amount (LCY)" := 4000;
                            RequestsToApprove."Available Credit Limit (LCY)" := 0;
                            RequestsToApprove."Pending Approvals" := 2;
                            //RequestsToApprove."Record ID to Approve" := 'Record ID to Approve';
                            RequestsToApprove."Number of Approved Requests" := 2;
                            RequestsToApprove."Number of Rejected Requests" := 0;
                            RequestsToApprove."Entry No." := rec.EntryNo;
                            //RequestsToApprove."Workflow Step Instance ID" := '{b38a5b1e-4142-440c-b337-9a64dc075e2f}';


                            RequestsToApprove.Insert();

                        until Rec.Next() = 0;
                    end

                end;
            }
When I click the button the selected records are created in the Requests To Approve screen of Business Central, but some of the values are missing / incomplete.  For instance it says The Record Does not Exist under the details section.
pastedimage1592322443167v2.png
The Table Number I offer 50110 is a real table that I created, so I am uncertain if there is something that I am missing, or if there is a field I am not filling out properly, or what else I could possibly be missing.
The Workflow Step ID (which is currently commented out, but I have tested with it in is the Workflow step ID for a Sales Order Workflow I created (maybe this is the issue)?
 
After I approve this record I am going to update a flag that says these records are ready to be made into proper Sales Invoices (or other required document). And then create those in the system.
Any help you all can offer is appreciated.
  • Verified answer
    Andy Sather Profile Picture
    Microsoft Employee on at

    Hello  - We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

     

    https://www.yammer.com/dynamicsnavdev#/home

    https://dynamicsuser.net/nav/f/developers

     

    I will open this up to the community in case they have something to add.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 631 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 409 Super User 2026 Season 2

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 222 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans