📚 SAP Business One SDK Help

ApprovalRequestsService Object
See Also  Members  Example

Description

ApprovalRequestsService is a business object that manages the approval requests process in the SAP Business One environment.

This object enables users to do the following:

  • Get an approval request from the approval process.
  • Get a list of approval requests from the approval process.
  • Get a list of open approval requests from the approval process.
  • Update an approval request within the approval process.
  • Get data interfaces.

Source table: OWDD.

Object Model







Remarks

From the SAP Business One application, you can do the following:

  • Approve draft documents in the Request for Approval window when you are reviewing messages in the Messages/Alert Overview window.
  • Approve draft documents in the Approval Decision Report window when you generate a report of the status of draft documents requiring approval.

 

Approving draft documents from the Request for Approval window:

  1. Choose Window --> Messages/Alert Overview. The Messages/Alert Overview window appears.
  2. To display the details of the message in the Request for Document Approval area, select the required message.
  3. To open the Request for Approval window, click the link arrow.

  4. In the Decision list, select your decision for the approval request.

  5. Choose the Update button. An internal message is sent to the document originator regarding the approval.

Approving draft documents from the Approval Decision Report window:

  1. Choose Administration --> Approval Procedures --> Approval Decision Report. The Approval Decision Report - Selection Criteria window appears.

  2. To generate the report, choose the required criteria.

  3. Choose the OK button. The Approval Decision Report window appears.

  4. In the Answer column, select your decision for the approval request.

  5. Choose the Update button. An internal message is sent to the document originator regarding the approval.

Example

Getting approval request details and the draft document (C#)Copy Code
Dim oApprovalRequestsService As ApprovalRequestsService = oCompany.GetCompanyService().GetBusinessService(ServiceTypes.ApprovalRequestsService) 
Dim oApprovalRequest As ApprovalRequest = oApprovalRequestsService.GetDataInterface(ApprovalRequestsServiceDataInterfaces.arsApprovalRequest) 
Dim oApprovalRequestParams As ApprovalRequestParams = oApprovalRequestsService.GetDataInterface(ApprovalRequestsServiceDataInterfaces.arsApprovalRequestParams) 
 
oApprovalRequestParams.Code = indexNum ' The approval index 
 
' Get approval request details 
oApprovalRequest = oApprovalRequestsService.GetApprovalRequest(oApprovalRequestParams) 
 
txtDocType.Text = oApprovalRequest.ObjectType 
txtDocNo.Text = oApprovalRequest.ObjectEntry 
txtUser.Text = oApprovalRequest.OriginatorID.ToString 
txtCurrStage.Text = oApprovalRequest.CurrentStage 
txtRemarks.Text = oApprovalRequest.ApprovalRequestLines.Item(0).Remarks 
 
' Get draft document 
Dim oDraft As Documents = oCompany.GetBusinessObject(BoObjectTypes.oDrafts) 
 
If oApprovalRequest.ObjectType = 112 Then 
    oDraft.GetByKey(oApprovalRequest.ObjectEntry) 
 
    'Get actual document type. 
    txtRealDocType.Text = oDraft.DocObjectCode 
        End If 






Approving a request (C#)Copy Code
Dim oApprovalRequestsService As ApprovalRequestsService = oCompany.GetCompanyService().GetBusinessService(ServiceTypes.ApprovalRequestsService) 
Dim oApprovalRequestsParams As ApprovalRequestsParams = oApprovalRequestsService.GetDataInterface(ApprovalRequestsServiceDataInterfaces.arsApprovalRequestsParams) 
Dim oApprovalRequest As ApprovalRequest = oApprovalRequestsService.GetDataInterface(ApprovalRequestsServiceDataInterfaces.arsApprovalRequest) 
Dim oApprovalRequestParams As ApprovalRequestParams = oApprovalRequestsService.GetDataInterface(ApprovalRequestsServiceDataInterfaces.arsApprovalRequestParams) 
 
'Get request list 
oApprovalRequestsParams = oApprovalRequestsService.GetAllApprovalRequestsList() 
oApprovalRequestParams = oApprovalRequestsParams.Item(oApprovalRequestsParams.Count - 1) 
 
'Approve request  
oApprovalRequest = oApprovalRequestsService.GetApprovalRequest(oApprovalRequestParams) 
oApprovalRequest.ApprovalRequestDecisions.Add() 
oApprovalRequest.ApprovalRequestDecisions.Item(0).Remarks = "Approved" 
oApprovalRequest.ApprovalRequestDecisions.Item(0).Status = BoApprovalRequestStatusEnum.arsApproved 
 
' Incase we want to approve with another user, uncomment the following 2 lines 
'oApprovalRequest.ApprovalRequestDecisions.Item(0).ApproverUserName = B1User 
'oApprovalRequest.ApprovalRequestDecisions.Item(0).ApproverPassword = B1Password 
 
Try 
    oApprovalRequestsService.UpdateRequest(oApprovalRequest) 
Catch ex As Exception 
    MessageBox.Show(ex.Message) 
End Try 

See Also