# new JSEvent Object - cannot set properties

**URL:** <https://forum.servoy.com/t/new-jsevent-object-cannot-set-properties/12184>\
**Category:** Classic Servoy\
**Created:** [May 12, 2010, 5:23pm UTC](https://forum.servoy.com/t/new-jsevent-object-cannot-set-properties/12184 "2010-05-12T17:23:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lenore](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Lenore](https://forum.servoy.com/u/Lenore)\
**Post date:** [May 12, 2010, 5:23pm UTC](https://forum.servoy.com/t/new-jsevent-object-cannot-set-properties/12184/1 "2010-05-12T17:23:57Z")

</div>

I am calling a function that is linked to the onAction of a button element. Since this method is dependent upon an event to get the form name, element name etc, I am creating a new JSEvent object and passing it to the function.

I tried to add the form and element name directly to the object with something like, event.setFormName or event.form = myFormName. This would allow me to use the Servoys native commands to retrieve this value from the object. The only way I could find to do this was to use the event.data object. This will work, but adds additional code in the receiving method to use the actual event properties or the event data object.

Is there another way to populate the properties in the native event object?

Here is the code using the data object.

```auto
//queue click on button
var _newEvent = new JSEvent();
_newEvent.data = new Object();
_newEvent.data.formName = _form;
newEvent.data.elementName = _associatedButton;
globals.comm_popup_openPopup(_newEvent)

```

Thanks in advance,

Lenore

---

<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:** [May 12, 2010, 6:13pm UTC](https://forum.servoy.com/t/new-jsevent-object-cannot-set-properties/12184/2 "2010-05-12T18:13:43Z")

</div>

+1  
I would love to see such feature, so that we can build or own, JSEvent Object…

---

<div class="post-metadata">

**Author:** ![Karel\_Broer](https://avatars.discourse-cdn.com/v4/letter/k/bcef8e/32.png) [@Karel\_Broer](https://forum.servoy.com/u/Karel_Broer)\
**Post date:** [May 12, 2010, 7:12pm UTC](https://forum.servoy.com/t/new-jsevent-object-cannot-set-properties/12184/3 "2010-05-12T19:12:44Z")

</div>

+1 vote from me. Great idea.

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [May 13, 2010, 9:10am UTC](https://forum.servoy.com/t/new-jsevent-object-cannot-set-properties/12184/4 "2010-05-13T09:10:46Z")

</div>

try this:

```auto
    //queue click on button
    var _newEvent = new Object();
    _newEvent.data = new Object();
    _newEvent.formName = _form;
    newEvent.elementName = _associatedButton;
    globals.comm_popup_openPopup(_newEvent)

```

that will behave the same as a JSEvent object it self.

currently we dont support updating values of the jsevent object they are readonly (except data)

they should be readonly because strange unexpected things can happen if scripts can just change them (if you pass the event object around)  
Better would then to have something like

```auto
var event = new JSEvent(formname,elementname,xxx)

```
