# runNamedQuery error unable to coerce to a map

**URL:** <https://forum.inductiveautomation.com/t/runnamedquery-error-unable-to-coerce-to-a-map/95736>\
**Category:** Ignition\
**Created:** [September 9, 2024, 3:34pm UTC](https://forum.inductiveautomation.com/t/runnamedquery-error-unable-to-coerce-to-a-map/95736 "2024-09-09T15:34:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zach\_Larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zach_larson/32/54388_2.png) [@Zach\_Larson](https://forum.inductiveautomation.com/u/Zach_Larson)\
**Post date:** [September 9, 2024, 3:34pm UTC](https://forum.inductiveautomation.com/t/runnamedquery-error-unable-to-coerce-to-a-map/95736/1 "2024-09-09T15:34:18Z")

</div>

My first question, is if am putting in the project name right because when I go to the manual, the project name seems to go first when gateway scoped.  
Then I put the path, and then the params.

My next question is how am I supposed to be putting in datetime datatype parameters.  
I tried '2024/09/08 07:00:00' as a string.  
I tried using dates derived from system.date.now().

I think either a parameter is wrong or the call is not working.  
I am trying to run from the script console.  
I am working there for testing to make a gateway event script.

Because it says that it can't coerce to a map though, I have to think the issue is in the params most likely.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [September 9, 2024, 3:42pm UTC](https://forum.inductiveautomation.com/t/runnamedquery-error-unable-to-coerce-to-a-map/95736/2 "2024-09-09T15:42:06Z")

</div>

Show your script but usually I get this when I the params are not a dict.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 9, 2024, 3:49pm UTC](https://forum.inductiveautomation.com/t/runnamedquery-error-unable-to-coerce-to-a-map/95736/3 "2024-09-09T15:49:21Z")

</div>

> [@Zach\_Larson](#):
>
> I am trying to run from the script console.  
> I am working there for testing to make a gateway event script.

You cannot. When the function signature for the different scopes is incompatible, you simply cannot run the actual gateway script code in the designer script console.

---

<div class="post-metadata">

**Author:** ![Zach\_Larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zach_larson/32/54388_2.png) [@Zach\_Larson](https://forum.inductiveautomation.com/u/Zach_Larson)\
**Post date:** [September 9, 2024, 3:49pm UTC](https://forum.inductiveautomation.com/t/runnamedquery-error-unable-to-coerce-to-a-map/95736/4 "2024-09-09T15:49:30Z")

</div>

I see that it is trying to receive my path as the parameters.  
It does not like that I tried to place the project name.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/d/6dddb586b772f8b35538afab5cf3f51fe09bedf4.png)

my script is like

```python
today = system.date.midnight(system.date.now())
yesterday = system.date.addHours(today,-24)

params = { 'place': 'Narnia', 'minDay': yesterday, 'maxDay':today}
data1 = system.db.runNamedQuery( 'myProjectName', 'folderName/queryName',params)

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 9, 2024, 3:53pm UTC](https://forum.inductiveautomation.com/t/runnamedquery-error-unable-to-coerce-to-a-map/95736/5 "2024-09-09T15:53:35Z")

</div>

Consider placing your test code in a library function, and use my [runInGateway](https://www.automation-pros.com/toolkit/doc/utility.html#runingateway) decorator.

Then you can call that script function in the designer and it will run in the gateway, returning your result back to the designer.
