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.
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.