Hi,
This is my scripted data source of a report.
And this is my key browser -
Why can i not view the scripted data source here? Am i missing something?
Thanks!
Quick checks:
Have you hit Save since you added that script? And:
Are you getting any errors? Either when you move to the design or preview screens, or in the gateway logs?
Maybe try executing the code on script console as well to check if you are getting the result that you want.
I get an 'ImportError: cannot import name IgnitionGateway'
Friendly tip: instead of posting pictures of code, use three back ticks (```) at the top and bottom of the code block, and paste the code block in directly, so it looks like this:
def updateData(data, sample):
from com.inductiveautomation.ignition.gateway import IgnitionGatemay
from com.inductiveautomation.ignition.gateway.images import ImageRecord
context = IgnitionGatemay.get()
imageManager = context.getImageManager()
user = data ['userName']
params = {'username': user}
imagePath = system.db.runNamedQuery('...')
if imagePath:
path = imagePath[15:]
data['image_path'] = path
imageData = imageManager.getImage(data['imagepath'])
imageBytes = imageData.getBytes(ImageRecord.Data)
data['imageBytes'] = imageBytes
return data
It makes it much easier for us to examine and troubleshoot the code when we can copy, quote, and reference specific lines.
That's not valid syntax, which is likely why it's not working. What are you trying to do?
What is the data type of the report parameter?
If slicing isn't supported, you might be getting a runtime error in your script, which would explain why your script isn't working as you expect.
Try writing the output to a different data key; see if the original then shows up. Then try adding logging statements to see whether your script is being executed/when it's failing:
def updateData(data, sample):
log = system.util.getLogger("report-debug")
CupSerialNo = data["CupSerialNo"]
log.info("starting updateData")
data["CupSerialNo_debug"] = CupSerialNo[4:]
log.info("finished updateData")
Here's what's happening -
Script Data Source -
def updateData(data, sample):
log = system.util.getLogger("report-debug")
CupSerialNo = data["CupSerialNo"]
log.info("starting updateData"+CupSerialNo)
data["test"] = CupSerialNo[4:]
log.info("finished updateData"+data["test"])
Parameters -
Logs - I'm concatenating the resulting string to the end of the message just so i can confirm the script is running...

But the key browser
-
Still not sure why...

...
Are you just overwriting the parameter on purpose?
Try something like this
def updateData(data, sample):
CupSerialNo = data["CupSerialNo"]
data["CupSerialNoTruncated"] = CupSerialNo[4:]
As you can see in the above thread, Paul suggested the same, but it did not work...