> ## Documentation Index
> Fetch the complete documentation index at: https://help.dingtalk.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Groovy Scripts

> How to use Groovy scripts to control approver rules in the advanced workflow designer. Covers prerequisites, procedure, and Groovy script examples for automatically assigning different approvers based on form input values.

In the advanced workflow designer, when you configure approver rules for a user task node, selecting **Other rules** reveals a **Groovy request** option. Write a Groovy script to control approvers based on your business needs.

## Prerequisites

Before using Groovy scripts, familiarize yourself with Groovy. For details, see the [W3C Groovy tutorial](https://www.w3cschool.cn/groovy/groovy_overview.html) and the [Apache Groovy introduction](http://www.groovy-lang.org/).

## Procedure

This example determines the finance approver based on the number entered in an input field. Requests below 100 are approved by one approver, and requests above 100 are approved by another.

<Steps>
  <Step title="On the workflow form editing page, add a Single-line text box and copy its unique identifier" />

  <Step title="Configure the approval process: select the approval node > Approver rule > Other rules > Groovy rule" />
</Steps>

Use **Groovy request** for the approver of the finance approval node.

`textField_kov80fx9` is the unique identifier of the Single-line text box on the form.

**Note**: When editing a Groovy request script, use the `toInteger()` method because internal workflow variables are strings.

The `toInteger()` method is required by default. Use the following format as a reference:

Copy and use the following code directly:

```javascript theme={"theme":{"light":"github-light","dark":"github-dark"}}
if(uniqueIdOfSingleLineTextBox.toInteger()<100  {
         return['approverUserId']
    }  else  {
       return['approverUserId']
    }
```

This code means: when the number in the Single-line text box is less than 100, route the request to one approver; otherwise, route it to another.

You can return multiple approvers.
