# Cloning task in automation - error

**URL:** <https://community.fibery.io/t/cloning-task-in-automation-error/5649>\
**Category:** Get Help\
**Created:** [January 7, 2024, 9:34am UTC](https://community.fibery.io/t/cloning-task-in-automation-error/5649 "2024-01-07T09:34:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Giuse](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/giuse/32/8487_2.png) [@Giuse](https://community.fibery.io/u/Giuse)\
**Post date:** [January 7, 2024, 9:34am UTC](https://community.fibery.io/t/cloning-task-in-automation-error/5649/1 "2024-01-07T09:34:15Z")

</div>

Hi, I thought there was an action in button automation to clone current entity (and being able to updare some field), but there’s not - maybe a feature request 🙂 , so I found this [thread](https://community.fibery.io/t/done-duplicate-a-record/386/7) of 3 years ago where Polina showed the JS code to duplicate a record. I used that code as automation action and it seemed to work but at every execution in the activity log, the action is reported as failed with

```auto
Failed to execute Action "Script": (intermediate value) is not iterable

```

followed by the list of field that have been (correctly) copied into the cloned record…  
What is wrong or what should I do to catch the problem?  
I don’t know if in the meantime there is a simpler method to clone a record (creating a new task and assigning each field value is not an optimal solution since my table has more than 20 fields).  
Thanks!

Giuse

---

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [January 8, 2024, 5:16pm UTC](https://community.fibery.io/t/cloning-task-in-automation-error/5649/2 "2024-01-08T17:16:56Z")

</div>

> [@Giuse](#):
>
> what should I do to catch the problem?

My approach would be to add many console.log messages to track the code’s progress, so you can narrow down which line is causing the issue.

---

<div class="post-metadata">

**Author:** ![Giuse](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/giuse/32/8487_2.png) [@Giuse](https://community.fibery.io/u/Giuse)\
**Post date:** [January 11, 2024, 7:24pm UTC](https://community.fibery.io/t/cloning-task-in-automation-error/5649/3 "2024-01-11T19:24:30Z")

</div>

I found a first issue in Polina’s script for cloning task: if replacing

```auto
    const [{ result: newEntity }] = await fibery.createEntity(

```

with

```auto
    const newEntity = await fibery.createEntity(

```

one error is solved.  
But there is another error I cannot understand how to solve:  
`Cannot find type for ["$id"] param. Please, ensure that all parameters are passed as 'params' argument to query."`  
that refers to the query, in particular it seems the last line to throw the error

```auto
const newEntityDetails = await fibery.executeSingleCommand(
    {
        "command": "fibery.entity/query",
        "args": {
            "query": {
                "q/from": type,
                "q/select": {
                    "Id": "fibery/id",
                    "RichTextField": {
                        "Id": [richTextField.name, "fibery/id"],
                        "Secret": [richTextField.name, "Collaboration~Documents/secret"]
                    },
                },
                "q/where": ["=", ["fibery/id"], "$id"],
                "q/limit": 1
            },
            "params": { "$id": newEntity["fibery/id"] }
        }
    });

```

how to fix it? I can then post to the original thread with the fully working version of the cloning script for others interested.  
Thank you very much

Giuse

---

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [January 11, 2024, 8:32pm UTC](https://community.fibery.io/t/cloning-task-in-automation-error/5649/4 "2024-01-11T20:32:07Z")

</div>

Try this instead:

```auto
"params": { "$id": newEntity["Id"] }

```

---

<div class="post-metadata">

**Author:** ![Giuse](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/giuse/32/8487_2.png) [@Giuse](https://community.fibery.io/u/Giuse)\
**Post date:** [January 11, 2024, 8:48pm UTC](https://community.fibery.io/t/cloning-task-in-automation-error/5649/5 "2024-01-11T20:48:33Z")

</div>

Thanks Matt!!! Now it works
