Scripted data source not being displayed in key browser

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.

Changed a little bit of the code...Was getting an error at Line 10. Now the attached code does not result in any errors but the datasource still doesn't appear in the browser... However, in spite of this, after i manually typed in the binding text in the image Key, the image is being displayed...

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.

Hi

So, coming back to this query, this time i have a pretty simple script data source that is saved -

def updateData(data, sample):
	CupSerialNo = data["CupSerialNo"]
	data["CupSerialNo"] = sample CupSerialNo[4:] 

Still not sure why the data source is not showing up in the key browser...

Thanks!

That's not valid syntax, which is likely why it's not working. What are you trying to do?

i'm trying the slice the report parameter here

Here's the corrected syntax -

def updateData(data, sample):
    CupSerialNo = data["CupSerialNo"]
    data["CupSerialNo"] = CupSerialNo[4:] 

Key browser -

Scripted data source still not being displayed...

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...

image

But the key browser :confused: -

Still not sure why...

Waiting

...

Unfortunately I'm out of office/busy this whole week at ICC - you've got something odd enough that I'd recommend you get in contact with Support officially and they can investigate and hopefully help figure out what's going wrong.

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...