Comments Panel Extension Function NameError: self is not defined

I am defining the insertNote extension function for a Comments Panel, Ignition 7.9.7, and I am having trouble using the ‘self’ reference.

The Comments Panel is in a template, and the problem is occurring while testing in the template design window. I have enabled the insertNote extenstion function and have the following code:

name = self.name
print name

I get the following error:

  File "<extension-method insertNote>", line 15, in <module>
NameError: name 'self' is not defined

Update: None of the method’s arguments are available to me (self, note, filename, sticky)

Sound like you didn’t indent your code properly.

You are correct! Working with the “”" section of code threw off my perception a bit. Having the large block of text between the def and my code made me miss the indentation.

if this is the only code in the script:

name = self.name
print name

how is is not indented correctly?

It needs to be indented to the def of the function, where self is defined. for example:

def insertNote(self, note, filename, sticky):
	name = self.name
	print name