# Passing parameter(s) to Popup menu?

**URL:** <https://forum.inductiveautomation.com/t/passing-parameter-s-to-popup-menu/6036>\
**Category:** Ignition\
**Created:** [March 15, 2013, 11:33am UTC](https://forum.inductiveautomation.com/t/passing-parameter-s-to-popup-menu/6036 "2013-03-15T11:33:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [March 15, 2013, 11:33am UTC](https://forum.inductiveautomation.com/t/passing-parameter-s-to-popup-menu/6036/1 "2013-03-15T11:33:11Z")

</div>

How can pass parameter to popup menu (or function called by popup menu)?

I want to have a global script to show me a popup menu called Reset, when I right click on the label or text field. In this labels I show numbers, which occasionally needs to be reset to zero.

Because I have 20 fields on the screen, I need to pass to the popup menu function a parameter, so the function will know, which field values in database needs to be reset.

---

<div class="post-metadata">

**Author:** ![AlThePal](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/althepal/32/3603_2.png) [@AlThePal](https://forum.inductiveautomation.com/u/AlThePal)\
**Post date:** [March 18, 2013, 9:54am UTC](https://forum.inductiveautomation.com/t/passing-parameter-s-to-popup-menu/6036/2 "2013-03-18T09:54:48Z")

</div>

The easiest way to do this is with a custom property on each label:

1. Create a label, giving it a string custom property of ‘tagName’. Write the full path of the SQLTag to be reset to this property.

2. In both the mousePressed and mouseReleased events of the label (required so it will run cross-platform), put the following code:`menu = app.util.getPopup()
menu.show(event)`

3. Create a new module called ‘util’ in the Script Module Editor and put the following code in it:[code]def getPopup():  
import system

If you want to reset to any other value you can change the value in the reset function. If you want to reset different points to different values, you will have to create another custom property for each label and use this within the reset function.

---

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [March 18, 2013, 1:38pm UTC](https://forum.inductiveautomation.com/t/passing-parameter-s-to-popup-menu/6036/3 "2013-03-18T13:38:45Z")

</div>

Thank you again. I didn’t even considered (remembered) custom properties (this is my first ‘real’ project)… 🙂

Over the weekend I found this way:

In the mouseReleased event I put:

```auto
menu = app.util.resetPopup("mesalo_egalizacija") <--- this is my filed name in DB
menu.show(event)
```

In ScriptModule Editor I create ‘util’ and put this:

```auto
def resetPopup(objekt):
	import system
	
	def reset(event):
		username = system.security.getUsername()
		roles = system.security.getRoles()
		if "Administrator" in roles:
			if system.gui.confirm("Do you really want to reset?", "UPOZORENJE!"):
				num = system.db.runUpdateQuery("UPDATE hour_meter SET " + objekt + " = 0 WHERE " + objekt + " <> 0;")
				system.gui.messageBox("Deleted rows: %d" % num)
		else:
			system.gui.messageBox("Only administrator can reset!")

	resetPopup = system.gui.createPopupMenu(["Reset"],[reset])
	return resetPopup
```

I guess, when I acquire some mileages it’ll get easier… 🙂

Regards from sLOVEnia  
Anton
