Source attribute error for input form to sql table in Ignition Perspective

Hello,

I have been trying to create a data entry form in ignition perspective. The issue is that I am getting an attribute error for the source for an onActionPerformed event. I am very confused, for I thought that onActionPerformed inherently knew what the source would be, or it would not be able to execute? I have even tried manually typing in the name of the button where source would go, but this does not work.

I already have a connection built between SQL server management studio with a SQL table built. There are many columns in this table, but I am just trying to have three columns populate at the moment. These three columns are being put into text input boxes, renamed to Maximum, Minimum, or Price. I want the user to press a button and have the data input go to these columns in the SQL table. The button and text inputs are all under the same coordinate container.

image
image

Script for Event:

def runAction(self, event):
	Maximum = event.source.parent.getComponent('Maximum').text
	Minimum = event.source.parent.getComponent('Minimum').text
	Price = event.source.parent.getComponent('Price').text
	
	system.db.runNamedQuery('AddNMR', {'Maximum':Maximum, 'Minimum':Minimum, 'Price':Price})

Correlated query:

Error Received:
Error running action 'component.onActionPerformed' on MyVieww/MyView@D/root/TabContainer/CoordinateContainer/Button: Traceback (most recent call last): File "function:runAction", line 2, in runAction AttributeError: 'com.inductiveautomation.ignition.common.script.ada' object has no attribute 'source'

This model was inspired by the back half of this post:
Inserting Data into a Database - Ignition User Manual 8.1 - Ignition Documentation (inductiveautomation.com)

Thanks!

The script was written for vision, and is not directly portable to perspective. Use the property selector in the event script editing dialog to select the properties you need. You will see that the path is significantly different.

4 Likes

That worked phenomenally! Thank you for the time and frustration save.

For the reference of those who might have this problem in the future, the working script:

def runAction(self, event):
	Maximum = self.getSibling("Minimum").props.text
	Minimum = self.getSibling("Minimum").props.text
	Price = self.getSibling("Price").props.text
	
	system.db.runNamedQuery('AddNMR', {'Maximum':Maximum, 'Minimum':Minimum, 'Price':Price})
2 Likes