diff --git a/Apps/W1/APIV2/app/src/pages/APIV2ApprovalEntries.Page.al b/Apps/W1/APIV2/app/src/pages/APIV2ApprovalEntries.Page.al new file mode 100644 index 0000000000..5be2d49652 --- /dev/null +++ b/Apps/W1/APIV2/app/src/pages/APIV2ApprovalEntries.Page.al @@ -0,0 +1,158 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace System.Automation; + +page 30094 "APIV2 - Approval Entries" +{ + APIGroup = 'auditing'; + APIPublisher = 'microsoft'; + APIVersion = 'v2.0'; + EntityCaption = 'Approval Entry'; + EntitySetCaption = 'Approval Entries'; + EntityName = 'approvalEntry'; + EntitySetName = 'approvalEntries'; + Editable = false; + DeleteAllowed = false; + InsertAllowed = false; + ModifyAllowed = false; + DataAccessIntent = ReadOnly; + PageType = API; + SourceTable = "Approval Entry"; + ODataKeyFields = SystemId; + + layout + { + area(Content) + { + repeater(Control1) + { + field(id; Rec.SystemId) + { + Caption = 'Id'; + } + field(entryNumber; Rec."Entry No.") + { + Caption = 'Entry No.'; + } + field(tableId; Rec."Table ID") + { + Caption = 'Table ID'; + } + field(documentType; Rec."Document Type") + { + Caption = 'Document Type'; + } + field(documentNumber; Rec."Document No.") + { + Caption = 'Document No.'; + } + field(sequenceNumber; Rec."Sequence No.") + { + Caption = 'Sequence No.'; + } + field(senderId; Rec."Sender ID") + { + Caption = 'Sender Id'; + } + field(senderName; Rec."Sender Full Name") + { + Caption = 'Sender Full Name'; + } + field(approvalCode; Rec."Approval Code") + { + Caption = 'Approval Code'; + } + field(salespersonPurchaserCode; Rec."Salespers./Purch. Code") + { + Caption = 'Salesperson/Purchaser Code'; + } + field(salespersonPurchaserName; Rec."Salespers./Purch. Name") + { + Caption = 'Salesperson/Purchaser Name'; + } + field(approverId; Rec."Approver ID") + { + Caption = 'Approver Id'; + } + field(approverName; Rec."Approver Full Name") + { + Caption = 'Approver Full Name'; + } + field(status; Rec.Status) + { + Caption = 'Status'; + } + field(dateTimeSentForApproval; Rec."Date-Time Sent for Approval") + { + Caption = 'Date-Time Sent for Approval'; + } + field(lastDateTimeModified; Rec."Last Date-Time Modified") + { + Caption = 'Last Date-Time Modified'; + } + field(comment; Rec.Comment) + { + Caption = 'Comment'; + } + field(dueDate; Rec."Due Date") + { + Caption = 'Due Date'; + } + field(amount; Rec.Amount) + { + Caption = 'Amount'; + } + field(amountLCY; Rec."Amount (LCY)") + { + Caption = 'Amount (LCY)'; + } + field(currencyCode; Rec."Currency Code") + { + Caption = 'Currency Code'; + } + field(approvalType; Rec."Approval Type") + { + Caption = 'Approval Type'; + } + field(limitType; Rec."Limit Type") + { + Caption = 'Limit Type'; + } + field(availableCreditLimitLCY; Rec."Available Credit Limit (LCY)") + { + Caption = 'Available Credit Limit (LCY)'; + } + field(pendingApprovals; Rec."Pending Approvals") + { + Caption = 'Pending Approvals'; + } + field(recordId; Rec."Record ID to Approve") + { + Caption = 'Record Id to Approve'; + } + field(delegationDateFormula; Rec."Delegation Date Formula") + { + Caption = 'Delegation Date Formula'; + } + field(numberOfApprovedRequests; Rec."Number of Approved Requests") + { + Caption = 'Number of Approved Requests'; + } + field(numberOfRejectedRequests; Rec."Number of Rejected Requests") + { + Caption = 'Number of Rejected Requests'; + } + field(relatedToChange; Rec."Related to Change") + { + Caption = 'Related to Change'; + } + field(workflowStepInstanceId; Rec."Workflow Step Instance ID") + { + Caption = 'Workflow Step Instance Id'; + } + } + } + } +} \ No newline at end of file diff --git a/Apps/W1/APIV2/app/src/pages/APIV2ApprovalUserSetup.Page.al b/Apps/W1/APIV2/app/src/pages/APIV2ApprovalUserSetup.Page.al new file mode 100644 index 0000000000..30b160d97f --- /dev/null +++ b/Apps/W1/APIV2/app/src/pages/APIV2ApprovalUserSetup.Page.al @@ -0,0 +1,108 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace System.Automation; +using System.Security.AccessControl; +using System.Security.User; + +page 30095 "APIV2 - Approval User Setup" +{ + APIGroup = 'auditing'; + APIPublisher = 'microsoft'; + APIVersion = 'v2.0'; + EntityCaption = 'Approval User Setup'; + EntitySetCaption = 'Approval User Setups'; + EntityName = 'approvalUserSetup'; + EntitySetName = 'approvalUserSetup'; + Editable = false; + DeleteAllowed = false; + InsertAllowed = false; + ModifyAllowed = false; + DataAccessIntent = ReadOnly; + PageType = API; + SourceTable = "User Setup"; + ODataKeyFields = SystemId; + + layout + { + area(Content) + { + repeater(Control1) + { + field(id; Rec.SystemId) + { + Caption = 'Id'; + } + field(userId; Rec."User ID") + { + Caption = 'User Id'; + } + field(userFullName; UserFullName) + { + Caption = 'User Full Name'; + } + field(salesPersonPurchaser; Rec."Salespers./Purch. Code") + { + Caption = 'Salespers./Purch. Code'; + } + field(approverId; Rec."Approver ID") + { + Caption = 'Approver Id'; + } + field(salesAmountApprovalLimit; Rec."Sales Amount Approval Limit") + { + Caption = 'Sales Amount Approval Limit'; + } + field(unlimitedSalesApproval; Rec."Unlimited Sales Approval") + { + Caption = 'Unlimited Sales Approval'; + } + field(purchaseAmountApprovalLimit; Rec."Purchase Amount Approval Limit") + { + Caption = 'Purchase Amount Approval Limit'; + } + field(unlimitedPurchaseApproval; Rec."Unlimited Purchase Approval") + { + Caption = 'Unlimited Purchase Approval'; + } + field(requestApprovalAmountLimit; Rec."Request Amount Approval Limit") + { + Caption = 'Request Amount Approval Limit'; + } + field(unlimitedRequestApprovalAmount; Rec."Unlimited Request Approval") + { + Caption = 'Unlimited Request Approval'; + } + field(substitute; Rec.Substitute) + { + Caption = 'Substitute'; + } + field(email; Rec."E-Mail") + { + Caption = 'E-Mail'; + } + field(phoneNumber; Rec."Phone No.") + { + Caption = 'Phone No.'; + } + field(approvalAdmin; Rec."Approval Administrator") + { + Caption = 'Approval Administrator'; + } + } + } + } + + var + UserFullName: Text; + + trigger OnAfterGetRecord() + var + User: Record User; + begin + User.SetRange("User Name", Rec."User ID"); + if User.FindFirst() then + UserFullName := User."Full Name"; + end; +} \ No newline at end of file diff --git a/Apps/W1/APIV2/app/src/pages/APIV2PstdApprovalEntries.Page.al b/Apps/W1/APIV2/app/src/pages/APIV2PstdApprovalEntries.Page.al new file mode 100644 index 0000000000..ee6d90b4e2 --- /dev/null +++ b/Apps/W1/APIV2/app/src/pages/APIV2PstdApprovalEntries.Page.al @@ -0,0 +1,150 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace System.Automation; + +page 30093 "APIV2 - Pstd. Approval Entries" +{ + APIGroup = 'auditing'; + APIPublisher = 'microsoft'; + APIVersion = 'v2.0'; + EntityCaption = 'Posted Approval Entry'; + EntitySetCaption = 'Posted Approval Entries'; + EntityName = 'postedApprovalEntry'; + EntitySetName = 'postedApprovalEntries'; + Editable = false; + DeleteAllowed = false; + InsertAllowed = false; + ModifyAllowed = false; + DataAccessIntent = ReadOnly; + PageType = API; + SourceTable = "Posted Approval Entry"; + ODataKeyFields = SystemId; + + layout + { + area(Content) + { + repeater(Control1) + { + field(id; Rec.SystemId) + { + Caption = 'Id'; + } + field(entryNumber; Rec."Entry No.") + { + Caption = 'Entry No.'; + } + field(tableId; Rec."Table ID") + { + Caption = 'Table Id'; + } + field(documentNumber; Rec."Document No.") + { + Caption = 'Document No.'; + } + field(sequenceNumber; Rec."Sequence No.") + { + Caption = 'Sequence No.'; + } + field(senderId; Rec."Sender ID") + { + Caption = 'Sender Id'; + } + field(senderName; Rec."Sender Full Name") + { + Caption = 'Sender Full Name'; + } + field(approvalCode; Rec."Approval Code") + { + Caption = 'Approval Code'; + } + field(salespersonPurchCode; Rec."Salespers./Purch. Code") + { + Caption = 'Salespers./Purch. Code'; + } + field(salespersonPurchName; Rec."Salespers./Purch. Name") + { + Caption = 'Salespers./Purch. Name'; + } + field(approverId; Rec."Approver ID") + { + Caption = 'Approver Id'; + } + field(approverName; Rec."Approver Full Name") + { + Caption = 'Approver Full Name'; + } + field(status; Rec.Status) + { + Caption = 'Status'; + } + field(dateTimeSentForApproval; Rec."Date-Time Sent for Approval") + { + Caption = 'Date-Time Sent for Approval'; + } + field(lastDateTimeModified; Rec."Last Date-Time Modified") + { + Caption = 'Last Date-Time Modified'; + } + field(lastModifiedById; Rec."Last Modified By ID") + { + Caption = 'Last Modified By Id'; + } + field(comment; Rec.Comment) + { + Caption = 'Comment'; + } + field(dueDate; Rec."Due Date") + { + Caption = 'Due Date'; + } + field(amount; Rec.Amount) + { + Caption = 'Amount'; + } + field(amountLCY; Rec."Amount (LCY)") + { + Caption = 'Amount (LCY)'; + } + field(currencyCode; Rec."Currency Code") + { + Caption = 'Currency Code'; + } + field(approvalType; Rec."Approval Type") + { + Caption = 'Approval Type'; + } + field(limitType; Rec."Limit Type") + { + Caption = 'Limit Type'; + } + field(availableCreditLimitLCY; Rec."Available Credit Limit (LCY)") + { + Caption = 'Available Credit Limit (LCY)'; + } + field(recordId; Rec."Posted Record ID") + { + Caption = 'Posted Record Id'; + } + field(delegationDateFormula; Rec."Delegation Date Formula") + { + Caption = 'Delegation Date Formula'; + } + field(numberOfApprovedRequests; Rec."Number of Approved Requests") + { + Caption = 'Number of Approved Requests'; + } + field(numberOfRejectedRequests; Rec."Number of Rejected Requests") + { + Caption = 'Number of Rejected Requests'; + } + field(iterationNumber; Rec."Iteration No.") + { + Caption = 'Iteration No.'; + } + } + } + } +} \ No newline at end of file diff --git a/Apps/W1/APIV2/app/src/pages/APIV2WorkflowApprovers.Page.al b/Apps/W1/APIV2/app/src/pages/APIV2WorkflowApprovers.Page.al new file mode 100644 index 0000000000..c314d72f84 --- /dev/null +++ b/Apps/W1/APIV2/app/src/pages/APIV2WorkflowApprovers.Page.al @@ -0,0 +1,97 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace System.Automation; + +page 2148 "APIV2 - Workflow Approvers" +{ + APIGroup = 'auditing'; + APIPublisher = 'microsoft'; + APIVersion = 'v2.0'; + ApplicationArea = All; + EntityCaption = 'Workflow Approver'; + EntitySetCaption = 'Workflow Approvers'; + EntityName = 'workflowApprover'; + EntitySetName = 'workflowApprovers'; + Editable = false; + DeleteAllowed = false; + InsertAllowed = false; + ModifyAllowed = false; + DataAccessIntent = ReadOnly; + PageType = API; + SourceTable = "Workflow Approvers Buffer"; + SourceTableTemporary = true; + ODataKeyFields = SystemId; + + layout + { + area(Content) + { + repeater(Control1) + { + field(id; Rec.SystemId) + { + Caption = 'Id'; + } + field(workflowCode; Rec.WorkflowCode) + { + Caption = 'Workflow Code'; + } + field(workflowDescription; Rec.WorkflowDescription) + { + Caption = 'Workflow Description'; + } + field(category; Rec.Category) + { + Caption = 'Category'; + } + field(enabled; Rec.Enabled) + { + Caption = 'Enabled'; + } + field(workflowStepId; Rec.WorkflowStepId) + { + Caption = 'Workflow Step Id'; + } + field(argumentId; Rec.ArgumentId) + { + Caption = 'Argument Id'; + } + field(approverType; Rec.ApproverType) + { + Caption = 'Approver Type'; + } + field(approverLimitType; Rec.ApproverLimitType) + { + Caption = 'Approver Limit Type'; + } + field(userGroupCode; Rec.UserGroupCode) + { + Caption = 'User Group Code'; + } + field(userGroupDescription; Rec.UserGroupDescription) + { + Caption = 'User Group Description'; + } + field(userId; Rec.UserId) + { + Caption = 'User Id'; + } + field(userName; Rec.UserName) + { + Caption = 'User Name'; + } + field(sequence; Rec.Sequence) + { + Caption = 'Sequence'; + } + } + } + } + + trigger OnInit() + begin + Rec.FillBuffer(); + end; +} \ No newline at end of file diff --git a/Apps/W1/APIV2/app/src/pages/APIV2WorkflowRespOptions.Page.al b/Apps/W1/APIV2/app/src/pages/APIV2WorkflowRespOptions.Page.al new file mode 100644 index 0000000000..542363107a --- /dev/null +++ b/Apps/W1/APIV2/app/src/pages/APIV2WorkflowRespOptions.Page.al @@ -0,0 +1,141 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace System.Automation; + +page 2146 "APIV2 - Workflow Resp. Options" +{ + APIGroup = 'auditing'; + APIPublisher = 'microsoft'; + APIVersion = 'v2.0'; + EntityCaption = 'Workflow Response Option'; + EntitySetCaption = 'Workflow Response Options'; + EntityName = 'workflowResponseOption'; + EntitySetName = 'workflowResponseOptions'; + Editable = false; + DeleteAllowed = false; + InsertAllowed = false; + ModifyAllowed = false; + DataAccessIntent = ReadOnly; + PageType = API; + SourceTable = "Workflow step argument"; + ODataKeyFields = SystemId; + layout + { + area(Content) + { + repeater(Control1) + { + field(systemId; Rec.SystemId) + { + Caption = 'System Id'; + } + field(id; Rec.ID) + { + Caption = 'Id'; + } + field(type; Rec."Type") + { + Caption = 'Type'; + } + field(generalJournalTemplateName; Rec."General Journal Template Name") + { + Caption = 'General Journal Template Name'; + } + field(generalJournalBatchName; Rec."General Journal Batch Name") + { + Caption = 'General Journal Batch Name'; + } + field(notificationUserId; Rec."Notification User ID") + { + Caption = 'Notification User Id'; + } + field(notificationUserLicenseType; Rec."Notification User License Type") + { + Caption = 'Notification User License Type'; + } + field(responseFunctionName; Rec."Response Function Name") + { + Caption = 'Response Function Name'; + } + field(notifySender; Rec."Notify Sender") + { + Caption = 'Notify Sender'; + } + field(linkTargetPage; Rec."Link Target Page") + { + Caption = 'Link Target Page'; + } + field(customLink; Rec."Custom Link") + { + Caption = 'Custom Link'; + } + field(eventConditions; Rec."Event Conditions") + { + Caption = 'Event Conditions'; + } + field(approverType; Rec."Approver Type") + { + Caption = 'Approver Type'; + } + field(approverLimitType; Rec."Approver Limit Type") + { + Caption = 'Approver Limit Type'; + } + field(workflowUserGroupCode; Rec."Workflow User Group Code") + { + Caption = 'Workflow User Group Code'; + } + field(dueDateFormula; Rec."Due Date Formula") + { + Caption = 'Due Date Formula'; + } + field(message; Rec.Message) + { + Caption = 'Message'; + } + field(delegateAfter; Rec."Delegate After") + { + Caption = 'Delegate After'; + } + field(showConfirmationMessage; Rec."Show Confirmation Message") + { + Caption = 'Show Confirmation Message'; + } + field(tableNumber; Rec."Table No.") + { + Caption = 'Table No.'; + } + field(fieldNumber; Rec."Field No.") + { + Caption = 'Field No.'; + } + field(fieldCaption; Rec."Field Caption") + { + Caption = 'Field Caption'; + } + field(approverUserId; Rec."Approver User ID") + { + Caption = 'Approver User Id'; + } + field(responseType; Rec."Response Type") + { + Caption = 'Response Type'; + } + field(responseUserId; Rec."Response User ID") + { + Caption = 'Response User Id'; + } + field(notificationEntryType; Rec."Notification Entry Type") + { + Caption = 'Notification Entry Type'; + } + field(responseOptionGroup; Rec."Response Option Group") + { + Caption = 'Response Option Group'; + } + } + } + } +} \ No newline at end of file diff --git a/Apps/W1/APIV2/app/src/pages/APIV2WorkflowSteps.Page.al b/Apps/W1/APIV2/app/src/pages/APIV2WorkflowSteps.Page.al new file mode 100644 index 0000000000..93030ea6cf --- /dev/null +++ b/Apps/W1/APIV2/app/src/pages/APIV2WorkflowSteps.Page.al @@ -0,0 +1,86 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace System.Automation; + +page 2147 "APIV2 - Workflow Steps" +{ + APIGroup = 'auditing'; + APIPublisher = 'microsoft'; + APIVersion = 'v2.0'; + EntityCaption = 'Workflow Step'; + EntitySetCaption = 'Workflow Steps'; + EntityName = 'workflowStep'; + EntitySetName = 'workflowSteps'; + Editable = false; + DeleteAllowed = false; + InsertAllowed = false; + ModifyAllowed = false; + DataAccessIntent = ReadOnly; + PageType = API; + SourceTable = "Workflow Step"; + ODataKeyFields = SystemId; + + layout + { + area(Content) + { + repeater(Control1) + { + field(systemId; Rec.SystemId) + { + Caption = 'System Id'; + } + field(id; Rec.ID) + { + Caption = 'Id'; + } + field(workflowCode; Rec."Workflow Code") + { + Caption = 'Workflow Code'; + } + field(description; Rec.Description) + { + Caption = 'Description'; + } + field(entryPoint; Rec."Entry Point") + { + Caption = 'Entry Point'; + } + field(previousWorkflowStepId; Rec."Previous Workflow Step ID") + { + Caption = 'Previous Workflow Step Id'; + } + field(nextWorkflowStepId; Rec."Next Workflow Step ID") + { + Caption = 'Next Workflow Step Id'; + } + field(type; Rec.Type) + { + Caption = 'Type'; + } + field(functionName; Rec."Function Name") + { + Caption = 'Function Name'; + } + field(argument; Rec.Argument) + { + Caption = 'Argument'; + } + field(sequenceNo; Rec."Sequence No.") + { + Caption = 'Sequence No.'; + } + part(workflowResponseOptions; "APIV2 - Workflow Resp. Options") + { + Caption = 'Workflow Response Options'; + EntityName = 'workflowResponseOption'; + EntitySetName = 'workflowResponseOptions'; + Multiplicity = Many; + SubPageLink = ID = field(Argument); + } + } + } + } +} \ No newline at end of file diff --git a/Apps/W1/APIV2/app/src/pages/APIV2Workflows.Page.al b/Apps/W1/APIV2/app/src/pages/APIV2Workflows.Page.al new file mode 100644 index 0000000000..e54b10107f --- /dev/null +++ b/Apps/W1/APIV2/app/src/pages/APIV2Workflows.Page.al @@ -0,0 +1,66 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace System.Automation; + +page 2145 "APIV2 - Workflows" +{ + APIGroup = 'auditing'; + APIPublisher = 'microsoft'; + APIVersion = 'v2.0'; + EntityCaption = 'Workflow'; + EntitySetCaption = 'Workflows'; + EntityName = 'workflow'; + EntitySetName = 'workflows'; + Editable = false; + DeleteAllowed = false; + InsertAllowed = false; + ModifyAllowed = false; + DataAccessIntent = ReadOnly; + PageType = API; + SourceTable = Workflow; + ODataKeyFields = SystemId; + + layout + { + area(Content) + { + repeater(Control1) + { + field(id; Rec.SystemId) + { + Caption = 'Id'; + } + field(code; Rec.Code) + { + Caption = 'Code'; + } + field(description; Rec.Description) + { + Caption = 'Description'; + } + field(enabled; Rec.Enabled) + { + Caption = 'Enabled'; + } + field(template; Rec.Template) + { + Caption = 'Template'; + } + field(category; Rec.Category) + { + Caption = 'Category'; + } + part(workflowSteps; "APIV2 - Workflow Steps") + { + Caption = 'Workflow Steps'; + EntityName = 'workflowStep'; + EntitySetName = 'workflowSteps'; + Multiplicity = Many; + SubPageLink = "Workflow Code" = field(Code); + } + } + } + } +} \ No newline at end of file diff --git a/Apps/W1/APIV2/test/src/APIV2ApprovalEntriesE2E.Codeunit.al b/Apps/W1/APIV2/test/src/APIV2ApprovalEntriesE2E.Codeunit.al new file mode 100644 index 0000000000..784660420d --- /dev/null +++ b/Apps/W1/APIV2/test/src/APIV2ApprovalEntriesE2E.Codeunit.al @@ -0,0 +1,47 @@ +codeunit 139910 "APIV2 - Approval Entries E2E" +{ + + Subtype = Test; + TestType = IntegrationTest; + TestPermissions = Disabled; + + var + Assert: Codeunit Assert; + LibraryApproval: Codeunit "Library - Document Approvals"; + LibrarySales: Codeunit "Library - Sales"; + LibraryGraphMgt: Codeunit "Library - Graph Mgt"; + ServiceNameTxt: Label 'approvalEntries'; + + + [Test] + procedure TestGetApprovalEntries() + var + ApprovalEntry: Record "Approval Entry"; + SalesHeader: Record "Sales Header"; + ApprovalEntryId: Text; + TargetURL: Text; + ResponseText: Text; + begin + // [SCENARIO] Check that approval entries can be retrieved via API + + // [GIVEN] a Sales order exists + LibrarySales.CreateSalesOrder(SalesHeader); + + // [GIVEN] the sales order has an approval entry + LibraryApproval.CreateApprovalEntryBasic(ApprovalEntry, Database::"Sales Header", Enum::"Approval Document Type"::Order, SalesHeader."No.", Enum::"Approval Status"::Open, Enum::"Workflow Approval Limit Type"::"Approval Limits", SalesHeader.RecordId(), Enum::"Workflow Approval Type"::Approver, Today(), SalesHeader.Amount); + ApprovalEntryId := Format(ApprovalEntry.SystemId); + + Commit(); + + // [WHEN] we GET the entry from the web service + ClearLastError(); + TargetURL := LibraryGraphMgt.CreateTargetURL(ApprovalEntryId, Page::"APIV2 - Approval Entries", ServiceNameTxt); + LibraryGraphMgt.GetFromWebService(ResponseText, TargetURL); + + // [THEN] entry should exist in the response + if GetLastErrorText() <> '' then + Assert.ExpectedError('Request failed with error: ' + GetLastErrorText()); + + Assert.IsTrue(LibraryGraphMgt.GetObjectIDFromJSON(ResponseText, 'id', ApprovalEntryId), 'Could not find approval entry'); + end; +} \ No newline at end of file diff --git a/Apps/W1/APIV2/test/src/APIV2ApprovalUserSetupE2E.Codeunit.al b/Apps/W1/APIV2/test/src/APIV2ApprovalUserSetupE2E.Codeunit.al new file mode 100644 index 0000000000..0bcde0b3cb --- /dev/null +++ b/Apps/W1/APIV2/test/src/APIV2ApprovalUserSetupE2E.Codeunit.al @@ -0,0 +1,42 @@ +codeunit 139912 "APIV2 - Approval UserSetup E2E" +{ + + Subtype = Test; + TestType = IntegrationTest; + TestPermissions = Disabled; + + var + Assert: Codeunit Assert; + LibraryApproval: Codeunit "Library - Document Approvals"; + LibraryGraphMgt: Codeunit "Library - Graph Mgt"; + ServiceNameTxt: Label 'approvalUserSetup'; + + + [Test] + procedure TestGetApprovalUserSetup() + var + UserSetup: Record "User Setup"; + UserSetupId: Text; + TargetURL: Text; + ResponseText: Text; + begin + // [SCENARIO] Check that approval user setup can be retrieved via API + + // [GIVEN] an Approval User Setup exists + LibraryApproval.CreateMockupUserSetup(UserSetup); + UserSetupId := Format(UserSetup.SystemId); + + Commit(); + + // [WHEN] we GET the entry from the web service + ClearLastError(); + TargetURL := LibraryGraphMgt.CreateTargetURL(UserSetupId, Page::"APIV2 - Approval User Setup", ServiceNameTxt); + LibraryGraphMgt.GetFromWebService(ResponseText, TargetURL); + + // [THEN] entry should exist in the response + if GetLastErrorText() <> '' then + Assert.ExpectedError('Request failed with error: ' + GetLastErrorText()); + + Assert.IsTrue(LibraryGraphMgt.GetObjectIDFromJSON(ResponseText, 'id', UserSetupId), 'Could not find approval user setup'); + end; +} \ No newline at end of file diff --git a/Apps/W1/APIV2/test/src/APIV2PstdApprovalEntriesE2E.Codeunit.al b/Apps/W1/APIV2/test/src/APIV2PstdApprovalEntriesE2E.Codeunit.al new file mode 100644 index 0000000000..f1cab97f94 --- /dev/null +++ b/Apps/W1/APIV2/test/src/APIV2PstdApprovalEntriesE2E.Codeunit.al @@ -0,0 +1,63 @@ +codeunit 139911 "APIV2 PstdApprovalEntries E2E" +{ + Subtype = Test; + TestType = IntegrationTest; + TestPermissions = Disabled; + + var + Assert: Codeunit Assert; + LibrarySales: Codeunit "Library - Sales"; + LibraryGraphMgt: Codeunit "Library - Graph Mgt"; + LibraryRandom: Codeunit "Library - Random"; + ServiceNameTxt: Label 'postedApprovalEntries'; + + + [Test] + procedure TestGetPostedApprovalEntries() + var + PostedApprovalEntry: Record "Posted Approval Entry"; + SalesHeader: Record "Sales Header"; + ApprovalEntryId: Text; + TargetURL: Text; + ResponseText: Text; + begin + // [SCENARIO] Check that posted approval entries can be retrieved via API + + // [GIVEN] a Sales order exists + LibrarySales.CreateSalesOrder(SalesHeader); + + // [GIVEN] the sales order has an approved approval entry + CreatePostedApprovalEntryBasic(PostedApprovalEntry, Database::"Sales Header", SalesHeader."No.", Enum::"Approval Status"::Approved, Enum::"Workflow Approval Limit Type"::"Approval Limits", SalesHeader.RecordId(), Enum::"Workflow Approval Type"::Approver, Today(), SalesHeader.Amount); + ApprovalEntryId := Format(PostedApprovalEntry.SystemId); + + Commit(); + + // [WHEN] we GET the entry from the web service + ClearLastError(); + TargetURL := LibraryGraphMgt.CreateTargetURL(ApprovalEntryId, Page::"APIV2 - Pstd. Approval Entries", ServiceNameTxt); + LibraryGraphMgt.GetFromWebService(ResponseText, TargetURL); + + // [THEN] entry should exist in the response + if GetLastErrorText() <> '' then + Assert.ExpectedError('Request failed with error: ' + GetLastErrorText()); + + Assert.IsTrue(LibraryGraphMgt.GetObjectIDFromJSON(ResponseText, 'id', ApprovalEntryId), 'Could not find posted approval entry'); + end; + + local procedure CreatePostedApprovalEntryBasic(var PostedApprovalEntry: Record "Posted Approval Entry"; TableId: Integer; DocumentNo: Code[20]; StatusOption: Enum "Approval Status"; LimitType: Enum "Workflow Approval Limit Type"; RecID: RecordID; ApprovalType: Enum "Workflow Approval Type"; DueDate: Date; AmountDec: Decimal) + begin + PostedApprovalEntry.Init(); + PostedApprovalEntry."Table ID" := TableId; + PostedApprovalEntry."Document No." := DocumentNo; + PostedApprovalEntry."Sequence No." := LibraryRandom.RandIntInRange(10000, 100000); + PostedApprovalEntry.Status := StatusOption; + PostedApprovalEntry."Limit Type" := LimitType; + PostedApprovalEntry."Posted Record ID" := RecID; + PostedApprovalEntry."Approval Type" := ApprovalType; + PostedApprovalEntry."Due Date" := DueDate; + PostedApprovalEntry.Amount := AmountDec; + PostedApprovalEntry."Approver ID" := CopyStr(UserId(), 1, 50); + PostedApprovalEntry.Insert(); + end; + +} \ No newline at end of file diff --git a/Apps/W1/APIV2/test/src/APIV2WorkflowApproversE2E.Codeunit.al b/Apps/W1/APIV2/test/src/APIV2WorkflowApproversE2E.Codeunit.al new file mode 100644 index 0000000000..b0292c1c49 --- /dev/null +++ b/Apps/W1/APIV2/test/src/APIV2WorkflowApproversE2E.Codeunit.al @@ -0,0 +1,67 @@ +codeunit 139913 "APIV2 - Workflow Approvers E2E" +{ + + Subtype = Test; + TestType = IntegrationTest; + TestPermissions = Disabled; + + var + Assert: Codeunit Assert; + LibraryWorkflow: Codeunit "Library - Workflow"; + LibraryPermissions: Codeunit "Library - Permissions"; + LibraryGraphMgt: Codeunit "Library - Graph Mgt"; + WorkflowEventHandling: Codeunit "Workflow Event Handling"; + WorkflowResponseHandling: Codeunit "Workflow Response Handling"; + ServiceNameTxt: Label 'workflowApprovers'; + + + [Test] + procedure TestGetApprovalEntries() + var + Workflow: Record Workflow; + User: Record User; + WorkflowStep: Record "Workflow Step"; + Uri: Codeunit Uri; + UriBuilder: Codeunit "Uri Builder"; + EntryPointEventID: Integer; + ResponseID: Integer; + UserId: Text; + TargetURL: Text; + ResponseText: Text; + begin + // [SCENARIO] Check that workflow approvers can be retrieved via API + // [GIVEN] A workflow exists + LibraryWorkflow.CreateWorkflow(Workflow); + + // [GIVEN] The workflow has an approval step for a specific approver + LibraryPermissions.CreateUser(User, CreateGuid(), false); + UserId := Format(User.SystemId); + EntryPointEventID := LibraryWorkflow.InsertEntryPointEventStep(Workflow, WorkflowEventHandling.RunWorkflowOnSendSalesDocForApprovalCode()); + ResponseID := LibraryWorkflow.InsertResponseStep(Workflow, WorkflowResponseHandling.CreateApprovalRequestsCode(), EntryPointEventID); + WorkflowStep.Get(Workflow.Code, ResponseID); + LibraryWorkflow.InsertApprovalArgument(ResponseID, Enum::"Workflow Approver Type"::Approver, enum::"Workflow Approver Limit Type"::"Specific Approver", '', true); + LibraryWorkflow.UpdateWorkflowStepArgumentApproverLimitType(WorkflowStep.Argument, Enum::"Workflow Approver Type"::Approver, enum::"Workflow Approver Limit Type"::"Specific Approver", '', User."User Name"); + + Commit(); + + // [WHEN] we GET the entry from the web service + ClearLastError(); + TargetURL := LibraryGraphMgt.CreateTargetURL('', Page::"APIV2 - Workflow Approvers", ServiceNameTxt); + UriBuilder.Init(TargetURL); + UriBuilder.AddQueryParameter('$filter', 'workflowCode eq ''' + Format(Workflow.Code) + ''''); + UriBuilder.GetUri(Uri); + TargetURL := Uri.GetAbsoluteUri(); + + LibraryGraphMgt.GetFromWebService(ResponseText, TargetURL); + + // [THEN] entry should exist in the response + if GetLastErrorText() <> '' then + Assert.ExpectedError('Request failed with error: ' + GetLastErrorText()); + + Assert.IsTrue(LibraryGraphMgt.GetPropertyValueFromJSON(ResponseText, 'value', ResponseText), 'Could not find values collection in response'); + + ResponseText := LibraryGraphMgt.GetObjectFromCollectionByIndex(ResponseText, 0); + + Assert.IsTrue(LibraryGraphMgt.GetObjectIDFromJSON(ResponseText, 'userId', UserId), 'Could not find workflow approver'); + end; +} \ No newline at end of file diff --git a/Apps/W1/APIV2/test/src/APIV2WorkflowsE2E.Codeunit.al b/Apps/W1/APIV2/test/src/APIV2WorkflowsE2E.Codeunit.al new file mode 100644 index 0000000000..16ff760d18 --- /dev/null +++ b/Apps/W1/APIV2/test/src/APIV2WorkflowsE2E.Codeunit.al @@ -0,0 +1,40 @@ +codeunit 139914 "APIV2 - Workflows E2E" +{ + + Subtype = Test; + TestType = IntegrationTest; + TestPermissions = Disabled; + + var + Assert: Codeunit Assert; + LibraryWorkflow: Codeunit "Library - Workflow"; + LibraryGraphMgt: Codeunit "Library - Graph Mgt"; + ServiceNameTxt: Label 'workflows'; + + + [Test] + procedure TestGetApprovalEntries() + var + Workflow: Record Workflow; + WorkFlowId: Text; + TargetURL: Text; + ResponseText: Text; + begin + // [SCENARIO] Check that workflows can be retrieved via API + // [GIVEN] A workflow exists + LibraryWorkflow.CreateWorkflow(Workflow); + WorkFlowId := Format(Workflow.SystemId); + Commit(); + + // [WHEN] we GET the entry from the web service + ClearLastError(); + TargetURL := LibraryGraphMgt.CreateTargetURL(WorkFlowId, Page::"APIV2 - Workflows", ServiceNameTxt); + LibraryGraphMgt.GetFromWebService(ResponseText, TargetURL); + + // [THEN] entry should exist in the response + if GetLastErrorText() <> '' then + Assert.ExpectedError('Request failed with error: ' + GetLastErrorText()); + + Assert.IsTrue(LibraryGraphMgt.GetObjectIDFromJSON(ResponseText, 'id', WorkFlowId), 'Could not find workflow'); + end; +} \ No newline at end of file