I'm using a change script that is working but it is also throwing an error. The script works perfectly and all the custom properties are being assigned correctly. But this error above is still showing up.
Self.custom.ContractDrpdwn is bond to a dropdown box component. The value and option of that dropdown component is bond to a dataset memory tag that is normally 30 x 1 dataset.
When this change script is triggered it takes the full name that is selected from the dropdown list and I need to slice that full name down to the first 6 characters.
That sliced full name is used later in a search and data call to the database.
I've tried to take contractdrpdwn and convert it to a pyDataset and a regular Dataset it doesn't allow it to happen.
Both properties self.custom.ContractDrpdwn and self.custom.Ket data is working correctly. The error still pops up and I'm trying get rid of that error.
Why is this error coming up and how can I solve this issue.
If you edit your original post to remove the screenshot, and instead paste your code in a code block, the code will be much easier for forum members to review.
The error is directing you to line 6, and proclaiming that the BasicDataset is unsubscriptable - presumably your FullContractName property.
Are you certain this is the correct script for that error?
Is there any chance that another version of this script also lives elsewhere?
The issue was that your FullContractName property was holding a dataset, not a string.
The proper way to fix it is to change how its data is computed.
I expect you have a binding on it. Modify this binding to extract the value you need from the dataset.
Maybe I'm the only one, but I totally disagree with pasting code instead of screenshots for identification of errors like this one. Code blocks don't have row numbers, and even if they did they're not guaranteed to be the same as the original code. Then it just makes it harder to explain which row is failing
@nminchin, @pascal.fragnoud: As the author of the linked article I agree that context is useful in some situations. If we're to add line numbers to the forum's pre-formatted code block can they be omitted from the clipboard copy function?
You're not. To assert myself 'on the fence' - I certainly referenced the screenshot to get the insight needed (row number) for follow-up questions. That said, I appreciate (& value) consistency for a standard where possible. Copying the code block to a script console to obtain row numbers, but also any potential formatting issues & typos, etc., seems preferrable to 'the forum'.
To expand on my initial questions:
How is the possible when there is an error on line 6? Since when does code continue executing following a runtime error (w/o exception handling)?
The OP is not handling the case where this script fires before a binding has delivered a proper value to self.custom.FullContractName, and then fires shortly after and succeeds.