> 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/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).

# JSステップでの「return」と「引数」の利用例

JSステップでは **return** と **引数** を利用することができ、これらを利用することで標準機能ではできない動作も実現できる可能性がございます。 本記事では、「return」と「引数」の具体的な利用例を見ていきましょう。

### JSステップや動的な値の利用方法

この記事では「JSステップ」と「動的な値」機能を利用しておりますが、基本的な使い方については触れておりません。基本的な使い方に関しては、下記のページでご案内しておりますのでご確認ください。

* [JSステップ](https://help.autify.com/nocode-web/autify-university/advanced/js-steps/javascript-steps.md)
* [動的な値の生成](https://help.autify.com/nocode-web/autify-university/foundation/creating-a-scenario/dynamic-value-generation.md)

## 利用例

利用例として以下の動作を目標に、どのように実現するか見ていきましょう。

* **動的な値で生成したランダムな文字列の先頭に、固定文字「TEST」を追加し、「TEST + ランダム文字列」の値を入力ステップで入力する**

#### 1. 動的な値でランダムな文字列を生成する

まずはランダムな文字列を生成するため、シナリオに「動的な値」ステップを追加し、 **ランダム文字列** を指定します。 今回はデフォルトで設定されているlengthとcharactersで設定します。

![](https://50135409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fof7cb8AGXhWvWThq3R0w%2Fuploads%2Fgit-blob-6eb2d1d8985c4561a7af1fb4052cff30e95002ed%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-20%2022.59.23.png?alt=media)

#### 2. JSステップを作成して「引数」を追加する

次にJSステップを追加し、JSステップの\[引数を追加]より **引数** を追加します。

![](https://50135409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fof7cb8AGXhWvWThq3R0w%2Fuploads%2Fgit-blob-9f28043ac1ae7daa6b0baca64445a3139998f9d6%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-20%2023.01.42.png?alt=media)

今回は「random」という名前をつけて引数を追加します。

![](https://50135409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fof7cb8AGXhWvWThq3R0w%2Fuploads%2Fgit-blob-3c53ae2a2271db6f64e0e2b2f031c20bde644bc3%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-20%2023.02.16.png?alt=media)

引数の値で **他ステップから取得** を選択し、1の手順で作成した **ランダム文字列** を利用したいため、ステップ2を指定します。

![](https://50135409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fof7cb8AGXhWvWThq3R0w%2Fuploads%2Fgit-blob-7179594259d5f3756ee0458391f0269eabc904af%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-20%2023.02.44.png?alt=media)

#### 3. JSステップで「TEST」をランダム文字の先頭に追加し、値を「return」する

2の手順で追加した引数「random」には、指定しているステップ2のランダムな文字列が代入されるため、下記のように記述し、固定文字「TEST」をランダム文字列の先頭に追加します。また、この値を後続ステップで利用したいため、 **return** をします。

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

![](https://50135409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fof7cb8AGXhWvWThq3R0w%2Fuploads%2Fgit-blob-dcf379131c7bf91be5399066ca14cb42a00f50ce%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-20%2023.21.13.png?alt=media)

#### 4. 「return」した値を、後続のステップで利用する

今回はステップ4の入力ステップで **他のステップから取得** を選択し、作成したステップ3のJSステップを指定します。

![](https://50135409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fof7cb8AGXhWvWThq3R0w%2Fuploads%2Fgit-blob-d52999e5756f10828551c2a0113a9551ca85d454%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-20%2023.35.05.png?alt=media)

ここまでの設定で実際にテスト実行してみると、ステップ3では **「TEST + ランダム文字列」の文字列が「return」されており** 、ステップ4のスクリーンショットを確認すると、目標の動作が問題なく実現できたことが確認できました。

![](https://50135409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fof7cb8AGXhWvWThq3R0w%2Fuploads%2Fgit-blob-715b0c48d23306efe69bbfa1df693165d1ec141e%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-20%2023.39.55.png?alt=media)

![](https://50135409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fof7cb8AGXhWvWThq3R0w%2Fuploads%2Fgit-blob-97512e0bcba1874aa815f080d11224b9f0e41464%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-20%2023.40.10.png?alt=media)

このように「return」と「引数」を利用することで様々なことが実現できますので、ぜひお試しください！ JSステップのご利用に関して、ご質問がある場合には、お気軽にサポートまでお問い合わせください。


---

# 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/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.
