# View.params object passing to script - error while accessing list dictionary item

**URL:** <https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [March 24, 2022, 12:10pm UTC](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578 "2022-03-24T12:10:48Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 24, 2022, 12:10pm UTC](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578/1 "2022-03-24T12:10:48Z")

</div>

I have the following view parameter on a view

```auto
shiftPattern : [
		{"dayName": "Monday", "shiftStart1": "08:00", "shiftStart2": "16:30", "shiftStart3": "00:00", "shiftEnable2": true, "shiftEnable3": true, "shiftNextDay3": true, "dayNumber": 0},
		{"dayName": "Tuesday", "shiftStart1": "08:00", "shiftStart2": "16:30", "shiftStart3": "00:00", "shiftEnable2": true, "shiftEnable3": true, "shiftNextDay3": true, "dayNumber": 1},
		{"dayName": "Wednesday", "shiftStart1": "08:00", "shiftStart2": "16:30", "shiftStart3": "00:00", "shiftEnable2": true, "shiftEnable3": true, "shiftNextDay3": true, "dayNumber": 2},
		{"dayName": "Thursday", "shiftStart1": "08:00", "shiftStart2": "16:30", "shiftStart3": "00:00", "shiftEnable2": true, "shiftEnable3": true, "shiftNextDay3": true, "dayNumber": 3},
		{"dayName": "Friday", "shiftStart1": "08:00", "shiftStart2": "15:30", "shiftStart3": "22:00", "shiftEnable2": true, "shiftEnable3": true, "shiftNextDay3": false, "dayNumber": 4},
		{"dayName": "Saturday", "shiftStart1": "07:00", "shiftStart2": "19:00", "shiftStart3": "21:00", "shiftEnable2": true, "shiftEnable3": false,"shiftNextDay3": false, "dayNumber": 5},
		{"dayName": "Sunday", "shiftStart1": "07:00", "shiftStart2": "19:00", "shiftStart3": "21:00", "shiftEnable2": true, "shiftEnable3": false,"shiftNextDay3": false, "dayNumber": 6}
	]

```

When I pass it into my Project Library function I have a problem.

`return shiftPattern` seems to give me the whole list.

`return shiftPattern[0]` gives me what I expect (although without string quotes):  
`{dayName: Monday, shiftStart1: 08:00, shiftStart2: 16:30, shiftStart3: 00:00, ...}`

`return shiftPattern[0]['dayName']` gives me  
`Error_ExpressionEval("Error executing script for runScript() expression:<my script function name>`

A similar problem was discussed on [Qualified Value in Change Script Perspective](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151). Playing around with the answers in that I have had success with

`shiftPattern[0].value['dayName']` returning ‘Monday’.

Can anyone explain what’s going on?

---

<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:** [March 24, 2022, 12:22pm UTC](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578/2 "2022-03-24T12:22:06Z")

</div>

I’m sure someone else probably already knows what the problem is. First thing I would do though since I don’t know - what is the `type` of `shiftPattern[0]`?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 24, 2022, 12:25pm UTC](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578/3 "2022-03-24T12:25:20Z")

</div>

I had a breakthrough while you were writing your answer and I updated my question a bit. I’m out of trouble for now but would like to understand it more, thanks.

`type(shiftPattern[0])` returns  
`class com.inductiveautomation.perspective.comonImmutableQualifiedValue`

---

<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:** [March 24, 2022, 12:27pm UTC](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578/4 "2022-03-24T12:27:08Z")

</div>

So you are getting this type of thing back - [ImmutableQualifiedValue](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.0/com/inductiveautomation/perspective/common/ImmutableQualifiedValue.html)

Looks like it has a `getValue()` function. What do you get from trying that?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 24, 2022, 12:30pm UTC](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578/5 "2022-03-24T12:30:34Z")

</div>

`getValue(shiftPattern[0])` returns  
`[{dayName: Monday, shiftStart1: 08:00, shiftStart2: 16:30, shiftStart3: 00:00, ...}]`

---

<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:** [March 24, 2022, 12:32pm UTC](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578/6 "2022-03-24T12:32:48Z")

</div>

Interesting, so your code was `getValue(shiftPattern[0])`? I would have thought it would have needed to have been `shiftPattern[0].getValue()`. Either way, it looks like now you have access to your list of dictionaries and can do what you need to do now yes?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 24, 2022, 12:35pm UTC](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578/7 "2022-03-24T12:35:31Z")

</div>

Yes, that was my code.  
`shiftPattern[0].getValue()['dayName']` also returns ‘Monday’ as does  
`shiftPattern[0].value['dayName']`

---

<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:** [March 24, 2022, 12:38pm UTC](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578/8 "2022-03-24T12:38:01Z")

</div>

I think @pturmel mentioned in another thread that any `.getProperty()` type functions can also be accessed via just `.property` and in fact the `.property` method is slightly more performant.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 24, 2022, 12:40pm UTC](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578/9 "2022-03-24T12:40:56Z")

</div>

OK. Thanks for the follow up. I should be able to continue with the real work now!

---

<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:** [March 24, 2022, 12:41pm UTC](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578/10 "2022-03-24T12:41:35Z")

</div>

Yes, here:

> [@Send data from db to excel](https://forum.inductiveautomation.com/t/send-data-from-db-to-excel/56713/11):
>
> It is a shortcut. Like .quality above is short for .getQuality(). Jython automatically recognizes Java getters and setters that follow the NetBeans pattern and treats them as jython object attributes. object.getSomething() can be replaced with object.something. object.setSomething(newValue) can become object.something = newValue. For booleans, object.isSomething() becomes object.something. This is a standard across the Java ecosystem (JSP, Struts, et cetera).

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 24, 2022, 12:46pm UTC](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578/11 "2022-03-24T12:46:01Z")

</div>

Thanks, Phil, but why did this work from the script console,

```auto
	startDate = system.date.addDays(system.date.now(), -1)	# Yesterday for testing.
	startDate

	false = False	# Set the JSON value = Python value.
	true = True	# ... and here.
	shiftPattern = [
		{"dayName": "Monday", "shiftStart1": "08:00", "shiftStart2": "16:30", "shiftStart3": "00:00", "shiftEnable2": true, "shiftEnable3": true, "shiftNextDay3": true, "dayNumber": 0},
		{"dayName": "Tuesday", "shiftStart1": "08:00", "shiftStart2": "16:30", "shiftStart3": "00:00", "shiftEnable2": true, "shiftEnable3": true, "shiftNextDay3": true, "dayNumber": 1},
		{"dayName": "Wednesday", "shiftStart1": "08:00", "shiftStart2": "16:30", "shiftStart3": "00:00", "shiftEnable2": true, "shiftEnable3": true, "shiftNextDay3": true, "dayNumber": 2},
		{"dayName": "Thursday", "shiftStart1": "08:00", "shiftStart2": "16:30", "shiftStart3": "00:00", "shiftEnable2": true, "shiftEnable3": true, "shiftNextDay3": true, "dayNumber": 3},
		{"dayName": "Friday", "shiftStart1": "08:00", "shiftStart2": "15:30", "shiftStart3": "22:00", "shiftEnable2": true, "shiftEnable3": true, "shiftNextDay3": false, "dayNumber": 4},
		{"dayName": "Saturday", "shiftStart1": "07:00", "shiftStart2": "19:00", "shiftStart3": "21:00", "shiftEnable2": true, "shiftEnable3": false,"shiftNextDay3": false, "dayNumber": 5},
		{"dayName": "Sunday", "shiftStart1": "07:00", "shiftStart2": "19:00", "shiftStart3": "21:00", "shiftEnable2": true, "shiftEnable3": false,"shiftNextDay3": false, "dayNumber": 6}
	]
	
	shiftCalcs.shiftCalcs.shiftGenerator(startDate, shiftPattern)

```

but not from an expression binding,

```auto
runScript(
	"shiftCalcs.shiftCalcs.shiftGenerator", 
	2000,	// 2 secondupdate for debug.
	{session.custom.datePicker},
	{view.params.config.shiftPattern}
)

```

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [March 24, 2022, 1:12pm UTC](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578/12 "2022-03-24T13:12:48Z")

</div>

My guess would be because in the script console shiftPattern is a List of Dictionaries but in the expression it is a JSON string.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 24, 2022, 2:00pm UTC](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578/13 "2022-03-24T14:00:10Z")

</div>

That would explain it. Have you any idea how to convert it in Python?

```auto
import json
json.loads(shiftPattern[0])

```

still gives  
`Error_ExpressionEval("Error executing script for runScript() expression:<my function name>")`

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [March 24, 2022, 2:29pm UTC](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578/14 "2022-03-24T14:29:28Z")

</div>

i doubt its cuz its "json", QVs come from tags or databases,

> [@Transistor](#):
>
> `view.params.config.shiftPattern`

are you getting these from a tag/db?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 24, 2022, 2:32pm UTC](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578/15 "2022-03-24T14:32:42Z")

</div>

> [@victordcq](#):
>
> Are you getting these from a tag/db?

For now the JSON is pasted into the `view.params.config.shiftPattern` object.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [March 24, 2022, 2:34pm UTC](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578/16 "2022-03-24T14:34:38Z")

</div>

Use `system.util.jsonDecode()`

In your script, do something like:

```auto
shiftPat = system.util.jsonDecode(shiftPattern)
print shiftPat['dayName']

```

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [March 24, 2022, 2:35pm UTC](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578/17 "2022-03-24T14:35:02Z")

</div>

Are you sure because then i get `class com.inductiveautomation.perspective.gateway.script.DotReferenceJythonMap`

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/e/1e726212ecfe29442475b57932405b6e18cb9291.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/8/58b81a7fefe0631245ef712b398d27b697e4d061.png)

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [March 24, 2022, 2:35pm UTC](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578/18 "2022-03-24T14:35:30Z")

</div>

its not a json strng tho

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [March 24, 2022, 2:42pm UTC](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578/19 "2022-03-24T14:42:56Z")

</div>

Anyways instead of using runScript() why not use the transform script?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 24, 2022, 2:49pm UTC](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578/20 "2022-03-24T14:49:43Z")

</div>

It’s for a plant dashboard view with many widgets and on zoom in the views will be replaced with more detailed views. It makes sense in my application to do this in the Project Library, I think, rather than have the script on each widget.

It’s interesting that the script transform can read shiftPattern as a list of dictionaries but the Project Library script can’t. It’s frustrating too!

[Next page](https://forum.inductiveautomation.com/t/view-params-object-passing-to-script-error-while-accessing-list-dictionary-item/57578.md?page=2)
