xFlow
  • Overview
    • Introduction
    • Core Features
    • Architecture
      • High Level Architecture
      • Tech Stack
      • Deployment Flexibility
      • Performance and Scalability
      • Security Compliance
  • Getting Started
    • Installation
    • Quick Start
    • Configuration
  • Core Concepts
    • Serverless Workflow Specification
    • Workflow data handling
    • Workflow Expressions
    • Error handling
    • Input and Output schema definition
    • User Task
    • User Forms
      • Lowcode Form
      • Advanced User Form
    • AI Agents in Enterprise Business Processes
    • Comparisons
      • BPMN2
  • Developer Guide
    • Architecture
    • API Reference
    • Workflow States Reference
      • Event State
      • Operation State
      • Switch State
      • Parallel State
      • Inject State
      • ForEach State
      • Callback State
      • UserTask State
      • AIAgent State
      • AIAgentProxy State
      • UserProxyAgent State
      • AI Outbound Agent State
    • Workflow Functions
      • REST
      • GraphQL
      • Custom
        • Built-in Functions
        • Lowcoder Query Function
      • Function Auth
    • Workflow Secrets
    • Integrations
    • Workflow Modeler
    • Frontend Development
      • Forms
        • Lowcode Form
        • Advanced User Form
    • Serverless Workflow Development
      • Operation State
      • Switch State
      • Parallel State
      • ForEach State
      • Callback State
      • User Task State
    • AI Agent Development
      • AI Agent
        • Predefined LLM
        • LLM Configuration
        • Multi LLM Configuration
        • Chat Memory
        • Tools
        • Data Output
        • Agent Outcomes
      • AI Agent Proxy
        • AI Agents Integration
      • User Proxy Agent
      • xChatBot Integration
  • Examples
    • Basic Examples
    • Advanced Examples
      • Loan Approval Workflow
      • QMS AP Workflow
  • Administration
    • Monitoring and Logging
    • Security
    • Performance Tuning
  • Extensions and Customizations
    • Plugins and Add-ons
  • Troubleshooting
    • Common Issues
    • FAQs
  • Release Notes
    • Version History
    • Upcoming Features
  • Support
    • Contact Information
    • Community
Powered by GitBook
On this page
  1. Examples
  2. Advanced Examples

QMS AP Workflow

id: QMS_AP_REQUEST
name: QMS_AP_REQUEST Workflow
version: '1.0'
dataInputSchema:
  schema: >-
    {"$schema":"http://json-schema.org/draft-04/schema#","type":"object","properties":{"customer":{"type":"object","properties":{"name":{"type":"string"},"age":{"type":"integer"}},"required":["name","age"]},"results":{"type":"array","items":{}}},"required":["customer","results"]}
  failOnValidationErrors: true
metadata:
  startFormKey: 'LCD#65d6aad45a18672fd954d93d'
timeouts:
  workflowExecTimeout:
    duration: P1D
  actionExecTimeout: PT1M
retries:
  - name: WorkflowRetries
    delay: PT3S
    maxAttempts: 10
start:
  stateName: New
states:
  - name: New
    type: operation
    actions:
      - name: Create QmsAPRequest
        functionRef:
          refName: CreateQmsAPRequest
          arguments:
            code: '${ .customer.phone }'
            aggId: '${ uuid4 }'
            workflowId: '${ $procInst.workflowId }'
      - name: Test JS Code
        functionRef:
          refName: TestJsCode
          arguments:
            custName: '${ .customer.name }'
        actionDataFilter:
          useResults: false
    transition: 1. Tiếp nhận hồ sơ
  - name: Kê khai hồ sơ
    taskKey: taskRework
    type: usertask
    formKey: 'LCD#65d6aad45a18672fd954d93d'
    assignee: '${ $procInst.startUserId }'
    taskOutcomes:
      - code: Complete
        name: Gửi lại
        outcomeDecision: COMPLETED
        transition: 1. Tiếp nhận hồ sơ
      - code: Cancel
        name: Hủy hồ sơ
        outcomeDecision: CANCEL
        transition:
          end: true
    taskListeners:
      - taskEvent: created
        actionMode: sequential
        actions:
          - functionRef:
              refName: NotifyWhenUserTaskCreated
              arguments:
                custName: '${ .customer.name }'
      - taskEvent: completed
        actionMode: sequential
        actions:
          - functionRef:
              refName: UpdateQmsAPRequestStatus
              arguments:
                workflowId: '${ $procInst.workflowId }'
                authStat: W
    transition: 1. Tiếp nhận hồ sơ
  - name: 1. Tiếp nhận hồ sơ
    taskKey: taskBPMCApprove
    type: usertask
    formKey: 'LCD#65d6aad45a18672fd954d93d'
    candidateUsers: bpmc01@easternoil.com
    taskOutcomes:
      - code: Approve
        name: Đồng ý
        outcomeDecision: APPROVED
        transition: 2.1 Phân công xử lý
      - code: Reject
        name: Từ chối
        outcomeDecision: REJECTED
        transition: Kê khai hồ sơ
    taskListeners:
      - taskEvent: created
        actionMode: sequential
        actions:
          - functionRef:
              refName: NotifyWhenUserTaskCreated
              arguments:
                custName: '${ .customer.name }'
      - taskEvent: completed
        actionMode: sequential
        actions:
          - functionRef:
              refName: UpdateQmsAPRequestStatus
              arguments:
                workflowId: '${ $procInst.workflowId }'
                authStat: W
    transition: 2.1 Phân công xử lý
  - name: 2.1 Phân công xử lý
    taskKey: taskLDVHCHQPhanCong
    type: usertask
    formKey: 'LCD#65d6aad45a18672fd954d93d'
    assignee: ldvhchq@easternoil.com
    taskListeners:
      - taskEvent: created
        actionMode: sequential
        actions:
          - functionRef:
              refName: NotifyWhenUserTaskCreated
              arguments:
                custName: '${ .customer.name }'
      - taskEvent: completed
        actionMode: sequential
        actions:
          - functionRef:
              refName: UpdateQmsAPRequestStatus
              arguments:
                workflowId: '${ $procInst.workflowId }'
                authStat: W
    transition: 2.2 Xử lý hồ sơ
  - name: 2.2 Xử lý hồ sơ
    taskKey: taskCVXuLy
    type: usertask
    formKey: 'LCD#65d6aad45a18672fd954d93d'
    assignee: nvxl01@easternoil.com
    taskListeners:
      - taskEvent: created
        actionMode: sequential
        actions:
          - functionRef:
              refName: NotifyWhenUserTaskCreated
              arguments:
                custName: '${ .customer.name }'
      - taskEvent: completed
        actionMode: sequential
        actions:
          - functionRef:
              refName: UpdateQmsAPRequestStatus
              arguments:
                workflowId: '${ $procInst.workflowId }'
                authStat: W
    transition: 2.3 Xem xét & quyết định
  - name: 2.3 Xem xét & quyết định
    taskKey: taskLDVHCHQApprove
    type: usertask
    formKey: 'LCD#65d6aad45a18672fd954d93d'
    assignee: ldvhchq@easternoil.com
    taskOutcomes:
      - code: Approve
        name: Đồng ý
        outcomeDecision: APPROVED
        transition: 3. Kiểm tra thể thức
      - code: Reject
        name: Từ chối
        outcomeDecision: REJECTED
        transition: 2.2 Xử lý hồ sơ
      - code: Return
        name: Bổ sung hồ sơ
        outcomeDecision: RETURN
        transition: Kê khai hồ sơ
    taskListeners:
      - taskEvent: created
        actionMode: sequential
        actions:
          - functionRef:
              refName: NotifyWhenUserTaskCreated
              arguments:
                custName: '${ .customer.name }'
      - taskEvent: completed
        actionMode: sequential
        actions:
          - functionRef:
              refName: UpdateQmsAPRequestStatus
              arguments:
                workflowId: '${ $procInst.workflowId }'
                authStat: W
    transition: 3. Kiểm tra thể thức
  - name: 3. Kiểm tra thể thức
    taskKey: taskVPTCApprove
    type: usertask
    formKey: 'LCD#65d6aad45a18672fd954d93d'
    assignee: vptc@easternoil.com
    taskOutcomes:
      - code: Approve
        name: Đồng ý
        outcomeDecision: APPROVED
        transition: 4. Xem xét phê duyệt
      - code: Reject
        name: Từ chối
        outcomeDecision: REJECTED
        transition: 2.2 Xử lý hồ sơ
    taskListeners:
      - taskEvent: created
        actionMode: sequential
        actions:
          - functionRef:
              refName: NotifyWhenUserTaskCreated
              arguments:
                custName: '${ .customer.name }'
      - taskEvent: completed
        actionMode: sequential
        actions:
          - functionRef:
              refName: UpdateQmsAPRequestStatus
              arguments:
                workflowId: '${ $procInst.workflowId }'
                authStat: W
    transition: 4. Xem xét phê duyệt
  - name: 4. Xem xét phê duyệt
    taskKey: taskLDTCApprove
    type: usertask
    formKey: 'LCD#65d6aad45a18672fd954d93d'
    assignee: ldtc@easternoil.com
    taskOutcomes:
      - code: Approve
        name: Đồng ý
        outcomeDecision: APPROVED
        transition: Export & Sign Form
      - code: Reject
        name: Từ chối
        outcomeDecision: REJECTED
        transition: 2.2 Xử lý hồ sơ
    taskListeners:
      - taskEvent: created
        actionMode: sequential
        actions:
          - functionRef:
              refName: NotifyWhenUserTaskCreated
              arguments:
                custName: '${ .customer.name }'
      - taskEvent: completed
        actionMode: sequential
        actions:
          - functionRef:
              refName: UpdateQmsAPRequestStatus
              arguments:
                workflowId: '${ $procInst.workflowId }'
                authStat: W
    transition: Export & Sign Form
  - name: Export & Sign Form
    type: operation
    actions:
      - name: Invoke Export & Sign Form Function
        functionRef:
          refName: ExportAndSignForm
          arguments:
            custName: '${ .customer.name }'
    transition: 5. Cấp số & đóng dấu
  - name: 5. Cấp số & đóng dấu
    taskKey: taskVPTCStamp
    type: usertask
    formKey: 'LCD#65d6aad45a18672fd954d93d'
    assignee: vttc@easternoil.com
    taskListeners:
      - taskEvent: created
        actionMode: sequential
        actions:
          - functionRef:
              refName: NotifyWhenUserTaskCreated
              arguments:
                custName: '${ .customer.name }'
      - taskEvent: completed
        actionMode: sequential
        actions:
          - functionRef:
              refName: UpdateQmsAPRequestStatus
              arguments:
                workflowId: '${ $procInst.workflowId }'
                authStat: A
    transition: Đóng dấu
  - name: Đóng dấu
    type: operation
    actions:
      - name: Invoke StampForm Function
        functionRef:
          refName: StampForm
          arguments:
            custName: '${ .customer.name }'
        actionDataFilter:
          fromStateData: '${ .customer }'
    end: true
functions:
  - name: CreateQmsAPRequest
    type: custom
    operation: ExecuteQueryAction
    metadata:
      libraryQueryName: cmd.create.qms_ap_request
      libraryQueryRecordId: latest
      params: '["code", "aggId", "workflowId"]'
  - name: UpdateQmsAPRequestStatus
    type: custom
    operation: ExecuteQueryAction
    metadata:
      libraryQueryName: cmd.update.qms_ap_request_status
      libraryQueryRecordId: latest
      params: '["authStat", "workflowId"]'
  - name: NotifyWhenUserTaskCreated
    type: custom
    operation: ExecuteQueryAction
    metadata:
      libraryQueryName: cmd.mail.send_task_created
      libraryQueryRecordId: latest
      params: '["custName"]'
  - name: ExportAndSignForm
    type: custom
    operation: ExecuteQueryAction
    metadata:
      libraryQueryName: cmd.notif.log
      libraryQueryRecordId: latest
      params: '["custName"]'
  - name: StampForm
    type: custom
    operation: ExecuteQueryAction
    metadata:
      libraryQueryName: cmd.notif.log
      libraryQueryRecordId: latest
      params: '["custName"]'
  - name: TestJsCode
    type: custom
    operation: RunJs
    metadata:
      jsCode: return 'Hello' + custName1;
      params: '["custName"]'
events:
  - name: NewApplicationEvent
    type: com.a4b.xflow.engine.StateData
    source: xflowengine
  - name: UserTaskCreated
    type: com.a4b.xptask.event.post.user_task.UserTaskCreatedEvent
  - name: UserTaskCompleted
    type: com.a4b.xptask.event.post.user_task.UserTaskCompletedEvent
errors:
  - name: Not allowed to transfer money
    code: (.+) not allowed to transfer money
    description: User was not allowed to transfer money
  - name: Underage denied
    code: Transferring money is denied for underage
    description: Transferring money is denied for underage individuals.
PreviousLoan Approval WorkflowNextAdministration

Last updated 11 months ago