> For the complete documentation index, see [llms.txt](https://help.autify.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.autify.com/nocode-web/en/tips-1/js-steps-tips/example-of-using-return-and-argument-at-js-step.md). Agents can also search and read this documentation through its [MCP server](https://help.autify.com/~gitbook/mcp).

# Examples of using Return and arguments in JS Steps

JS Steps support ***return*** and ***arguments***, which may make it possible to perform actions that you can't achieve with the standard features. In this article, we will look at an example that uses *return* and *arguments*.

### How to Use JS Steps and Dynamic Values

We will use JS Steps and the Dynamic Values in this article, but we will not cover the basics of how to use these features. To learn the basics, please refer to the following pages:

* [JS Steps](https://help.autify.com/nocode-web/en/autify-university/advanced/js-steps/javascript-steps.md)
* [Generating Dynamic Values](https://help.autify.com/nocode-web/en/autify-university/foundation/creating-a-scenario/dynamic-value-generation.md)

## Example

As an example, let's look at how to achieve the following actions:

* **Add the fixed character "TEST" in front of the random text generated by the Dynamic Value feature, and enter the returned value "TEST + random text" in an input step.**

### 1. Generate a random text using Dynamic Values

First, we want to generate a random text. Add a Dynamic Value step to the scenario and specify **\[Random text with specific characters].** In this example, we will use the default settings for its length and characters.

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-5555c97fe2c434be06d887a90d814155dbf4eb90%2F%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88%202023-09-22%2015.49.00\(1\).png?alt=media)

### 2. Create a JS Step and add an argument

Next, add a JS Step and add an **argument** by clicking **\[Add argument]** in the JS Step.

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-cfd65e4c8701406759684a6d8505267de146d84b%2F%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88%202023-09-22%2015.49.41.png?alt=media)

In this example, we will name it **"random"** add the argument.

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-8231b06add01ba3b5c9c3ed9229c058bd5ea7d68%2F%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88%202023-09-22%2015.49.57.png?alt=media)

We want to use the **\[Random text with specific characters]** we created in step 1 above, so under **Argument values**, select **\[Other step's result]** and specify **\[2. Dynamic Value]**.

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-bdc9b854e103e573061809ff29e37022e47fb982%2F%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88%202023-09-22%2015.50.35.png?alt=media)

### 3. In the JS Step, add "TEST" in front of the random text and return the value

The random text specified in \[2. Dynamic Value] will be assigned to the **"random"** argument we added in step 2 above, so we will write the following JavaScript to add the fixed string "TEST" in front of the random text. We will also return the value so that we can use it in subsequent steps.

```js
return "TEST" + random;
```

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-a1c6e12094d7fa6104331a450aa9aff54f01d063%2F%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88%202023-09-22%2015.52.31.png?alt=media)

### 4. Use the returned value in a subsequent step

In the Input step in step 4, select **\[Other step's result]** and specify **\[3. Execute JavaScript]**, which is the JS Step we just created.

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-fce3633451148aee746bfaafe30798196631d3f3%2F%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88%202023-09-22%2015.53.21.png?alt=media)

When we run the test with this setup, **step 3 returns "TEST + random text"**, and from the screenshot in step 4, we can confirm that the target action was performed correctly.

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-64b34fd29a483c9a92aa505d08018d3245a671eb%2F%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88%202023-09-22%2016.02.20.png?alt=media)

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-7016662b21462b5c674c3065c402fa60b51e3929%2F%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88%202023-09-22%2016.02.28.png?alt=media)

As you can see, you can test a wide range of actions using return and arguments. If you have any questions about using JS Steps, please feel free to contact support.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.autify.com/nocode-web/en/tips-1/js-steps-tips/example-of-using-return-and-argument-at-js-step.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
