See this picture of the drop down:
My code is:
if event.source.parent.getComponent(‘Dropdown’).selectedStringValue == “Labeling” :
#The event is not triggered as it should be, I have some logic that runs properly with no if statement, I seem to be running into the problem at this point. The if statement is not returning true even though I believe it is true.
Do you have “Labeling” for both the value and the display label (ie both columns in your dataset)? If not, try changing your script to use .selectedLabel
I can’t help but notice the ellipses at the end. It looks like the text in your dropdown is being truncated. Is there a lot of trailing space at the end of
Labeling? If so, then the string comparison is going to fail unless you’re including the trailing spaces.
Thank you but unfortunately there is no space after the word labeling. I am the one who filled out the data for inside the drop down. It reflects a custom entry in a SQL table. “Labeling” as a string should be the only thing there. There are some longer items on the drop down that need the ellipses, and it looks like Ignition might put them there.
Even if the box is longer the ellipses are there.
I have tried using both of those values (.selectedString and .selectedLabel) and my label is also the same on top of that.
What is the field type in the database table?
Ahhh… It is nchar(50), maybe nvarchar(50) would help?
Yes and that alludes to Pauls response.
nchar(50) will append spaces to the end of the actual text to fill to 50 characters.
Or just trim the whitespace off the string before the comparison if you don’t want to change the datatype. (I think strip() does that?)
Thanks for the input Kathy, that is an interesting point.