# Script console runNamedQuery different than perspective binding transform

**URL:** <https://forum.inductiveautomation.com/t/script-console-runnamedquery-different-than-perspective-binding-transform/113161>\
**Category:** Ignition\
**Tags:** perspective, ignition81, scripting\
**Created:** [January 8, 2026, 7:59pm UTC](https://forum.inductiveautomation.com/t/script-console-runnamedquery-different-than-perspective-binding-transform/113161 "2026-01-08T19:59:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leor\_Fishman](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Leor\_Fishman](https://forum.inductiveautomation.com/u/Leor_Fishman)\
**Post date:** [January 8, 2026, 7:59pm UTC](https://forum.inductiveautomation.com/t/script-console-runnamedquery-different-than-perspective-binding-transform/113161/1 "2026-01-08T19:59:21Z")

</div>

The following transform:

```python
def transform(self, value, quality, timestamp):
# Get the period selection value
period_value = value
# Get current time
now = system.date.now()
period_start = system.date.addHours(now, -24)
period_end = now
# Call the named query
result = system.db.runNamedQuery("get_top5_machines", {"period_start": period_start,
      "period_end": period_end,
      "sort_order": "lowest"})

# Return the dataset
return result

```

returns an error script eval.

In the console,

`now = system.date.now()`  
`period_start = system.date.addHours(now, -24)`  
`period_end = now`  
`result = system.db.runNamedQuery(`  
`"get_top5_machines",`  
`{`  
`"period_start": period_start,`  
`"period_end": period_end,`  
`"sort_order": 'lowest'`  
`}`  
`)`  
`print(result)`

prints a pyDataSet.

RunNamedQuery definitely has perspective session scope. Help?

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [January 8, 2026, 8:03pm UTC](https://forum.inductiveautomation.com/t/script-console-runnamedquery-different-than-perspective-binding-transform/113161/2 "2026-01-08T20:03:17Z")

</div>

> [@Leor\_Fishman](#):
>
> `return result``

You have an extra quote mark

---

<div class="post-metadata">

**Author:** ![Leor\_Fishman](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Leor\_Fishman](https://forum.inductiveautomation.com/u/Leor_Fishman)\
**Post date:** [January 8, 2026, 8:04pm UTC](https://forum.inductiveautomation.com/t/script-console-runnamedquery-different-than-perspective-binding-transform/113161/3 "2026-01-08T20:04:40Z")

</div>

Copy paste error, thats not whats in the transform

just copying again for myself:

`def transform(self, value, quality, timestamp):`  
`# Get the period selection value`  
`period_value = value`  
`# Get current time`  
`now = system.date.now()`  
`period_start = system.date.addHours(now, -24)`  
`period_end = now`

```python
# Call the named query
result = system.db.runNamedQuery("get_top5_machines", {"period_start": period_start,
      "period_end": period_end,
      "sort_order": "lowest"})

# Return the dataset
return result

```

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [January 8, 2026, 8:08pm UTC](https://forum.inductiveautomation.com/t/script-console-runnamedquery-different-than-perspective-binding-transform/113161/4 "2026-01-08T20:08:21Z")

</div>

for multiline, use three backticks. one set on the line above, one on the line below.

```python
def transform(self, value, quality, timestamp):
# Get the period selection value
      period_value = value
# Get current time
      now = system.date.now() 
      period_start = system.date.addHours(now, -24)
      period_end = now

# Call the named query
      result = system.db.runNamedQuery("get_top5_machines", {"period_start": period_start, "period_end": period_end, "sort_order": "lowest"})
                                                                                                               
# Return the dataset
return result

```

---

<div class="post-metadata">

**Author:** ![Nol](https://avatars.discourse-cdn.com/v4/letter/n/8e8cbc/32.png) [@Nol](https://forum.inductiveautomation.com/u/Nol)\
**Post date:** [January 8, 2026, 8:10pm UTC](https://forum.inductiveautomation.com/t/script-console-runnamedquery-different-than-perspective-binding-transform/113161/5 "2026-01-08T20:10:54Z")

</div>

Perhaps it's a copy paste error to the forum but you do not have any indentation on the code below def transform.

Also couple other things. If it's a simple project then it'll auto assume the project name but if your project is using Inheritance then you need to specify the project name as additional parameter before the path.

And as a suggestion put your parameters separate then list it in the function, it's optional but just a better habit for down the road to organize things, especially if some queries get lengthy lists for parameters.

```python
def transform(self, value, quality, timestamp):

	project_name = "YourProjectName" 
	
	now = system.date.now()
	period_start = system.date.addHours(now, -24)
	period_end = now
	
	params = {
		"period_start": period_start,
		"period_end": period_end,
		"sort_order": "lowest"
	}

	result = system.db.runNamedQuery(project_name, "get_top5_machines", params)
	
	return result

```

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [January 8, 2026, 8:12pm UTC](https://forum.inductiveautomation.com/t/script-console-runnamedquery-different-than-perspective-binding-transform/113161/6 "2026-01-08T20:12:40Z")

</div>

Also, if you hover over the error icon, you should see more info on the error.
