# ability to pass values from the form to a method

**URL:** <https://forum.servoy.com/t/ability-to-pass-values-from-the-form-to-a-method/2603>\
**Category:** Classic Servoy\
**Created:** [August 31, 2004, 5:59am UTC](https://forum.servoy.com/t/ability-to-pass-values-from-the-form-to-a-method/2603 "2004-08-31T05:59:09Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![gstein](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@gstein](https://forum.servoy.com/u/gstein)\
**Post date:** [August 31, 2004, 5:59am UTC](https://forum.servoy.com/t/ability-to-pass-values-from-the-form-to-a-method/2603/1 "2004-08-31T05:59:09Z")

</div>

Example: OnAction = MyMethod(‘1’,RecordIndex)

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [August 31, 2004, 6:35am UTC](https://forum.servoy.com/t/ability-to-pass-values-from-the-form-to-a-method/2603/2 "2004-08-31T06:35:05Z")

</div>

hugh? ![:?]( "Confused")  
you can pass field if you want?!

OnAction = MyMethod(‘1’,field1)

---

<div class="post-metadata">

**Author:** ![gstein](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@gstein](https://forum.servoy.com/u/gstein)\
**Post date:** [August 31, 2004, 6:50am UTC](https://forum.servoy.com/t/ability-to-pass-values-from-the-form-to-a-method/2603/3 "2004-08-31T06:50:05Z")

</div>

I don’t think my example was clear.

What I want is on a form, in the OnAction event to call a method and write some values to pass to the method.

I know I can call a method from within a method and pass values between them, but right now that can’t be done from the form to the method. All we can do is select a method to put into a form event.

Or am I missing something?

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [August 31, 2004, 6:54am UTC](https://forum.servoy.com/t/ability-to-pass-values-from-the-form-to-a-method/2603/4 "2004-08-31T06:54:00Z")

</div>

Yes, I believe you are missing something ![:)]( "Smile")

you can do this:

var a = field1  
var b = field2  
MyMethod(a,b)

if you attach this to the onAction, this should work!

---

<div class="post-metadata">

**Author:** ![gstein](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@gstein](https://forum.servoy.com/u/gstein)\
**Post date:** [August 31, 2004, 8:39am UTC](https://forum.servoy.com/t/ability-to-pass-values-from-the-form-to-a-method/2603/5 "2004-08-31T08:39:31Z")

</div>

Again, it seems I have not made myself clear.

Your example calls a second method from within a first method that is attached to an event on a form. I know you can do that.

What I am asking for is the ability to pass values into a method, directly from the event which calls the method.

Right now, if I want to attach a method to the onAction event of a form, I can only select it from the available methods. What I want is to be able to select it from the available methods and write one or more values that I can send to the method directly from the form event.

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [August 31, 2004, 9:14am UTC](https://forum.servoy.com/t/ability-to-pass-values-from-the-form-to-a-method/2603/6 "2004-08-31T09:14:03Z")

</div>

In the onAction method, you can access the data on the form.

In the Method Editor, look under Application\Forms%%your\_formname%%\Elements

There you find all the elements you have on your form, IF you gave the elements a name!!! If you named them, they will show up there and then you can get their values.

Hope it helps,

Paul

---

<div class="post-metadata">

**Author:** ![gstein](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@gstein](https://forum.servoy.com/u/gstein)\
**Post date:** [August 31, 2004, 9:52am UTC](https://forum.servoy.com/t/ability-to-pass-values-from-the-form-to-a-method/2603/7 "2004-08-31T09:52:14Z")

</div>

I know that. But there are times, like in my original example, where I would like to pass a value to a method from the form, with a value that is not on the form. That is what I am asking for.

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [August 31, 2004, 9:58am UTC](https://forum.servoy.com/t/ability-to-pass-values-from-the-form-to-a-method/2603/8 "2004-08-31T09:58:40Z")

</div>

Which value are you talking about then?

If the value is not on your form, it must be either a global or a value from another form or a related value. All can be accessed through the Method Editor tree.

If that doesn’t work for you, please give a more clear example of which value you’re trying to pass

Paul

---

<div class="post-metadata">

**Author:** ![gstein](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@gstein](https://forum.servoy.com/u/gstein)\
**Post date:** [August 31, 2004, 10:33am UTC](https://forum.servoy.com/t/ability-to-pass-values-from-the-form-to-a-method/2603/9 "2004-08-31T10:33:43Z")

</div>

Lets say in lots pf places in my application I have delete buttons and I want all of them to go to one global method where I will have all of my delete routines. I would like, in the event which call to the method to send the method two values which are not on the form – the first is whether to popup a confirm message and the second is which stored procedure to run. So what I would like to put on the form OnAction event is something like: DelRec(1,“spDelPeople”). That would tell the funtion to first popup a confirm button and then run the spDelPeople stored procedure.

I know I can just call the DelRec method and from there I can look and see which button on which form called the method and I could create some login with that to do the same thing – but that is a whole lot more non-generic code than what would be needed if I could just send those two values from the form directly.

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [August 31, 2004, 10:45am UTC](https://forum.servoy.com/t/ability-to-pass-values-from-the-form-to-a-method/2603/10 "2004-08-31T10:45:46Z")

</div>

OK, example is clear. But it’s not possible ![:(]( "Sad")

Best bet is making a lookup table with columnc formname, button,popup and sp.

When the generic method is triggered, you get current formname and methodtriggerelement, with that lookup the proper record in your lookup table and get the values of the columns popup and sp. And with those results shoe or not show the popup and execute the SP.

this way it’s still generic, I think.

Hope it helps.

---

<div class="post-metadata">

**Author:** ![gstein](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@gstein](https://forum.servoy.com/u/gstein)\
**Post date:** [August 31, 2004, 10:50am UTC](https://forum.servoy.com/t/ability-to-pass-values-from-the-form-to-a-method/2603/11 "2004-08-31T10:50:10Z")

</div>

Yeah. There are lots of work-arounds, none of them nearly as elegant as what I am asking for. Thats why I asked for it.
