How to identify the button pressed

Hi all,

In FM I could point several buttons to the same method using a scriptparameter.
With some if statements I could distinguish which button was pressed and run
parts of the method.
This must be very simple but I can’t see how.

if (forms.main.elements[‘name’] == ‘buttonname1’ )
{
//do stuff
}
if (forms.main.elements[‘name’] == ‘buttonname2’ )
{
//do stuff
}

Hi Ron,

You just give the buttons a unique name and use the following piece of code to fetch the clicked buttonname:

var _sBtn = application.getMethodTriggerElementName();

Then you simply can use a switch statement to do your stuff:

switch(_sBtn)
{
case "buttonname1":
   //do stuff
   break;
case "buttonname2":
   //do stuff
   break;
case "buttonname3":
   //do stuff
   break;
}

Just make sure the name property of the button(s) is filled.

Hope this helps

Thanks very much Robert.

Regard,
Ron