Hey everyone ,
I’m trying to write a date to a Dropdown
I tried writing to the drop down property in this way
value = [System]Client/User/DateTimeFormatShort.Value
event.source.parent.getComponent(‘Start Date’).dateValue = value
I also used the variation system.date.now
I think the error is on my understanding of the script editor and system tags.
I am doing this on a reset button. I’m using a button to reset the dropdown date value.
Does anyone have suggestion or point me in a direction to research?
Thanks.
To pass your value to the property you must first read the tag value by using the function “system.tag.readBlocking()” and providing the function with the list of tags this way:
#Your path is in brackets because the function takes a list of tags
#that you want to read.
#Also, your tag path should be between quotes since it's a string.
paths = ["[System]Client/User/DateTimeFormatShort"]
value = system.tag.readBlocking(paths)[0].value
#The [0] refers to your first and only tag path that you've read.
#The .value is necessary because the function returns a qualified value
#and you just need to pass the value of the tag.
event.source.parent.getComponent("Start Date").dateValue = value
You can just remove the text after # since they’re just comments, but the code should work if the tag path is correct and the reference to your object is also correct.
You can read more about the system.tag.readBlocking() function here:
https://docs.inductiveautomation.com/display/DOC81/system.tag.readBlocking
You can read more about the differences between scripting and expressions here:
https://docs.inductiveautomation.com/display/DOC81/Scripting+Vs.+SQL+Vs.+Expressions
And here:
https://docs.inductiveautomation.com/display/DOC81/Scripting+in+Ignition
Since you’ve asked for directions, Ignition also has the Inductive University where you can learn more about all the aspects of the software and i definetly recomend you complete these classes before going further. The University and the manual can get you pretty far.
https://inductiveuniversity.com/
1 Like
Like Leonardo suggested, you’ll have to read the tag first.
try the following:
value = [System]Client/User/DateTimeFormatShort.Value
event.source.parent.getComponent(‘Start Date’).dateValue = value
val = system.tag.read(“ System]Client/User/DateTimeFormatShort”).value
event.source.parent.getComponent(‘Start Date’).dateValue = val
If the above doesn’t work, try adding system.date.parse
After you read the date tag.
Thanks for your help with this this gives me a lot of direction I appreciate it.
Thanks for your help with this.