Global name 'self' is not defined in script

userName= getattr(self.session.custom, "userName")
global name 'self' is not defined showing error

This is not enough information to offer particularly useful troubleshooting advice.

Where is this script written? What arguments are you passing in, if it's a defined function? Where is it being called from?

1 Like

below Script define in project library .

self is not defined in your script. Change your function to def getRecord(self):, and then pass your source into the function when you call it.

6 Likes