# Qualified Value in Change Script Perspective

**URL:** <https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151>\
**Category:** Ignition\
**Created:** [June 24, 2021, 11:33am UTC](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151 "2021-06-24T11:33:17Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![User45199](https://avatars.discourse-cdn.com/v4/letter/u/41988e/32.png) [@User45199](https://forum.inductiveautomation.com/u/User45199)\
**Post date:** [June 24, 2021, 11:33am UTC](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151/1 "2021-06-24T11:33:17Z")

</div>

Hi everyone,  
I’m writing to you because I have a problem with a qualified value from a change script for the “items” property of a tree in perspective.  
There is 2 arguments natively implemented in the script, which are “currentValue” and “previousValue”, but when I try to access currentValue.value elements it throws me an error saying that there is no such arguments for this data.  
Here is what the currentValue.value looks like :

 ![currentValue.value](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/5/458ba158f4d31eb87b3c043033d4c42174dec853.png)

Here is the code :  
 ![code](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/7/d7b633dadee9dbdf23eca7a177689c1141707341.png)

But Then it just throws at me this error :

 ![error](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/8/b8620e514556270dd1e262eabd75cef2f27fc1c6.png)

I have tried currentValue[0].value, test[0].items(), test.items(), no success.  
Also it’s the same the other element of items (data, label, …)  
Thank you !

---

<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:** [June 24, 2021, 11:43am UTC](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151/2 "2021-06-24T11:43:17Z")

</div>

can you show us what it returns and if any of them work?  
`dict(test)`, `dict(test[0])`, `dict(currentValue)` and `dict(test['items'])`

---

<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:** [June 24, 2021, 12:16pm UTC](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151/3 "2021-06-24T12:16:18Z")

</div>

I see this as `text`, not `test`.

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

---

<div class="post-metadata">

**Author:** ![User45199](https://avatars.discourse-cdn.com/v4/letter/u/41988e/32.png) [@User45199](https://forum.inductiveautomation.com/u/User45199)\
**Post date:** [June 24, 2021, 12:58pm UTC](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151/4 "2021-06-24T12:58:58Z")

</div>

Thank you for you answer.  
Nonce of your suggestion works, here is the screenshots : :  
dict(test[0]) :

 ![dict(test0)](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/5/c5f86584cc15ce64e5c46c89bd1fbf663788d13a.png)  
dict(currentValue) :  
 ![dict(currentValue)](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/d/cd11cf10c4bbf65a954bc56e7fea54934da97a40.png)  
dict(test):  
 ![dict(test)](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/2/82c0b98de88367757c102d56b12871280b35c2ca.png)  
dict(test[‘items’]) neither

---

<div class="post-metadata">

**Author:** ![User45199](https://avatars.discourse-cdn.com/v4/letter/u/41988e/32.png) [@User45199](https://forum.inductiveautomation.com/u/User45199)\
**Post date:** [June 24, 2021, 12:59pm UTC](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151/5 "2021-06-24T12:59:59Z")

</div>

Thank you for you answer. Yeah this is normal, because i’m using a label component just to see the dada, so im displaying the data in the text property of the label

---

<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:** [June 24, 2021, 1:07pm UTC](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151/6 "2021-06-24T13:07:22Z")

</div>

```auto
TypeError: cannot convert dictionary update sequence element #0 to a sequence

```

ah this is interesting it means its an array not a dict

can you assign test to a custom key for a second and show us what it gives?  
like create a custom component (key) and do self.custom.key = test

---

<div class="post-metadata">

**Author:** ![User45199](https://avatars.discourse-cdn.com/v4/letter/u/41988e/32.png) [@User45199](https://forum.inductiveautomation.com/u/User45199)\
**Post date:** [June 24, 2021, 1:11pm UTC](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151/7 "2021-06-24T13:11:54Z")

</div>

I created a custom property (called “test”) for the label component and assigned test to it, here is what i get :  
 ![custom key](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/f/5f125f42eb66788e6903c78d665441eef5f96003.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:** [June 24, 2021, 1:14pm UTC](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151/8 "2021-06-24T13:14:05Z")

</div>

alright then test[0].items should be an array of the items  
(ofc no need to use the custom key in between)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/a/da489fa97589bb5542d10b792964c0ac3aa79b63.png)

---

<div class="post-metadata">

**Author:** ![User45199](https://avatars.discourse-cdn.com/v4/letter/u/41988e/32.png) [@User45199](https://forum.inductiveautomation.com/u/User45199)\
**Post date:** [June 24, 2021, 1:20pm UTC](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151/9 "2021-06-24T13:20:45Z")

</div>

Ok it works, looks like I can’t use directly “currentvalue.value”, I need to pass it to another custom property then use this property to do what I want. Don’t know why but anyway I will use that, thank you for your help !

---

<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:** [June 24, 2021, 1:21pm UTC](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151/10 "2021-06-24T13:21:33Z")

</div>

Oh it doesnt work without the custom?  
Then it might be that its a json string

---

<div class="post-metadata">

**Author:** ![User45199](https://avatars.discourse-cdn.com/v4/letter/u/41988e/32.png) [@User45199](https://forum.inductiveautomation.com/u/User45199)\
**Post date:** [June 24, 2021, 1:22pm UTC](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151/11 "2021-06-24T13:22:15Z")

</div>

So I would need to decode the json before using it ?

---

<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:** [June 24, 2021, 1:22pm UTC](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151/12 "2021-06-24T13:22:53Z")

</div>

Its worth a try xd

---

<div class="post-metadata">

**Author:** ![User45199](https://avatars.discourse-cdn.com/v4/letter/u/41988e/32.png) [@User45199](https://forum.inductiveautomation.com/u/User45199)\
**Post date:** [June 24, 2021, 1:23pm UTC](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151/13 "2021-06-24T13:23:51Z")

</div>

Ok thank you, I will try that and I would post the code here if I managed to do so !

---

<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:** [June 24, 2021, 1:24pm UTC](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151/14 "2021-06-24T13:24:11Z")

</div>

something like?

```auto
test = curval...

test = system.util.jsonDecode(test) 

self.get ...

```

do anything

---

<div class="post-metadata">

**Author:** ![User45199](https://avatars.discourse-cdn.com/v4/letter/u/41988e/32.png) [@User45199](https://forum.inductiveautomation.com/u/User45199)\
**Post date:** [June 24, 2021, 1:27pm UTC](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151/15 "2021-06-24T13:27:07Z")

</div>

Ok I tried that, but here is what I get :  
 ![error string](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/5/351395fcafa3c5137a376f602586e3a3e79434a6.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:** [June 24, 2021, 1:29pm UTC](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151/16 "2021-06-24T13:29:19Z")

</div>

Hm wierd xd  
what gives

> type(test)

?

---

<div class="post-metadata">

**Author:** ![User45199](https://avatars.discourse-cdn.com/v4/letter/u/41988e/32.png) [@User45199](https://forum.inductiveautomation.com/u/User45199)\
**Post date:** [June 24, 2021, 1:32pm UTC](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151/17 "2021-06-24T13:32:48Z")

</div>

This is what I get : class org.python.core.PyArray

---

<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:** [June 24, 2021, 1:35pm UTC](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151/18 "2021-06-24T13:35:26Z")

</div>

> [@User45199](#):
>
> org.python.core.PyArray

huh then i dont see why that didnt work before...  
maybe test[0] is the json?  
what does type(test[0]) give?

---

<div class="post-metadata">

**Author:** ![User45199](https://avatars.discourse-cdn.com/v4/letter/u/41988e/32.png) [@User45199](https://forum.inductiveautomation.com/u/User45199)\
**Post date:** [June 24, 2021, 1:38pm UTC](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151/19 "2021-06-24T13:38:57Z")

</div>

Here is the type of test[0] : class com.inductiveautomation.perspective.common.ImmutableQualifiedValue  
and the type of test[0].value is class java.util.HashMap

---

<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:** [June 24, 2021, 1:42pm UTC](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151/20 "2021-06-24T13:42:39Z")

</div>

oh weird, then this might work:  
`test[0].value.items`  
`test[0].getValue().items`  
or if that doesnt:  
`system.util.jsonDecode(test[0].toString()).items`  
surely should do something xd

[Next page](https://forum.inductiveautomation.com/t/qualified-value-in-change-script-perspective/48151.md?page=2)
