Qualified Value in Change Script Perspective

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 :

Here is the code :
code

But Then it just throws at me this error :

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 !

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

I see this as text, not test.

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


dict(currentValue) :

dict(test):

dict(test[‘items’]) neither

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

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

I created a custom property (called “test”) for the label component and assigned test to it, here is what i get :
custom key

alright then test[0].items should be an array of the items
(ofc no need to use the custom key in between)
image

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 !

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

1 Like

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

Its worth a try xd

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

something like?

test = curval...

test = system.util.jsonDecode(test) 

self.get ...

do anything

Ok I tried that, but here is what I get :
error string

Hm wierd xd
what gives

type(test)

?

This is what I get : class 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?

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

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