# Custom Method from Expression (runScript()) in Perspective

**URL:** <https://forum.inductiveautomation.com/t/custom-method-from-expression-runscript-in-perspective/35491>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [June 10, 2020, 12:36pm UTC](https://forum.inductiveautomation.com/t/custom-method-from-expression-runscript-in-perspective/35491 "2020-06-10T12:36:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kyle.tansill](https://avatars.discourse-cdn.com/v4/letter/k/d26b3c/32.png) [@kyle.tansill](https://forum.inductiveautomation.com/u/kyle.tansill)\
**Post date:** [June 10, 2020, 12:36pm UTC](https://forum.inductiveautomation.com/t/custom-method-from-expression-runscript-in-perspective/35491/1 "2020-06-10T12:36:27Z")

</div>

I have a custom method on a table component called populate(), the script runs fine from an event script but when calling it in an expression binding on the same component I am getting Error\_ExpressionEval. The method takes no arguments as it only accesses the custom properties on the component.

I have seen in previous posts that expression can access ‘self.’ in vision but is this the case in perspective. Am I wasting my time here?

For information, a functionally identical script works from the project. namespace

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [June 10, 2020, 12:45pm UTC](https://forum.inductiveautomation.com/t/custom-method-from-expression-runscript-in-perspective/35491/2 "2020-06-10T12:45:26Z")

</div>

How are you accessing custom properties on the component without feeding any parameters? Can you post the function populate?

---

<div class="post-metadata">

**Author:** ![kyle.tansill](https://avatars.discourse-cdn.com/v4/letter/k/d26b3c/32.png) [@kyle.tansill](https://forum.inductiveautomation.com/u/kyle.tansill)\
**Post date:** [June 10, 2020, 12:53pm UTC](https://forum.inductiveautomation.com/t/custom-method-from-expression-runscript-in-perspective/35491/3 "2020-06-10T12:53:35Z")

</div>

```auto
def populate(self):
	"""
	Custom method that can be invoked directly on this component.

	Arguments:
		self: A reference to the component that is invoking this function.
	"""
	import DbInterface.DbInterface as dbInterface
	
	# populate local var
	
	query = self.custom.query
	
	editable = self.custom.editableCols
	
	try:
	    visibleHeaders = eval(self.custom.visibleColumns)
	except TypeError:
	    visibleHeaders = self.custom.visibleColumns
	

```

Above is a code snippet of how the custom properties are accessed. This runs ok from an event script.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 10, 2020, 12:58pm UTC](https://forum.inductiveautomation.com/t/custom-method-from-expression-runscript-in-perspective/35491/4 "2020-06-10T12:58:40Z")

</div>

You need to pass on self into the function for it to work I believe, as I don’t think runScript will do this automatically.  
`runScript('shared.populate(self)', 0)`

---

<div class="post-metadata">

**Author:** ![kyle.tansill](https://avatars.discourse-cdn.com/v4/letter/k/d26b3c/32.png) [@kyle.tansill](https://forum.inductiveautomation.com/u/kyle.tansill)\
**Post date:** [June 10, 2020, 1:00pm UTC](https://forum.inductiveautomation.com/t/custom-method-from-expression-runscript-in-perspective/35491/5 "2020-06-10T13:00:31Z")

</div>

Sorry that is a misunderstanding. the snippet I posted is from within the custom method. I want to call the custom method from the expression as runScript(‘self.populate()’, 0 )

---

<div class="post-metadata">

**Author:** ![kyle.tansill](https://avatars.discourse-cdn.com/v4/letter/k/d26b3c/32.png) [@kyle.tansill](https://forum.inductiveautomation.com/u/kyle.tansill)\
**Post date:** [June 10, 2020, 1:01pm UTC](https://forum.inductiveautomation.com/t/custom-method-from-expression-runscript-in-perspective/35491/6 "2020-06-10T13:01:05Z")

</div>

ah sorry, OK I’ll try that… no passing self into the custom method didn’t work.
