# 'getMessage()' function not working in 3.1

**URL:** <https://forum.electra.one/t/getmessage-function-not-working-in-3-1/2036>\
**Category:** Bug reports\
**Tags:** lua\
**Created:** [April 29, 2023, 2:07pm UTC](https://forum.electra.one/t/getmessage-function-not-working-in-3-1/2036 "2023-04-29T14:07:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![urbanspaceman](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.electra.one/urbanspaceman/32/206_2.png) [@urbanspaceman](https://forum.electra.one/u/urbanspaceman)\
**Post date:** [April 29, 2023, 2:07pm UTC](https://forum.electra.one/t/getmessage-function-not-working-in-3-1/2036/1 "2023-04-29T14:07:02Z")

</div>

This was working fine in firmware 3.1.7 (in beta), but I had to roll back to 3.1 because of the envelope control freezing the E1.

I was using this to identify which control had been changed:

```auto
function parameterMap.onChange (valueObjects, origin, value)
    local paramNum = valueObjects[1]:getMessage():getParameterNumber()
end

```

…but now functions like ‘getMessage()’ and ‘getControl()’ get an error. If I print these:

```auto
print(valueObjects)
print(valueObjects[1])
print(valueObjects[1]:getMessage())
print(valueObjects["value"])

```

I get these results:

```auto
table: 0x20014440
userdata: 0x2001af30
error running function 'onChange': ctrlv2/p003.lua:137: attempt to index a userdata value (field 'integer index')
lua: nil

```

Similarly, the ‘getControl()’ function in the for loop in the manual throws the same ‘attempt to index a userdata value’ error

```auto
        for i, valueObject in ipairs (valueObjects) do
            local control = valueObject:getControl ()
            print (string.format ("affects control value %s.%s",
                control:getName (), valueObject:getId ()))
        end

```

---

<div class="post-metadata">

**Author:** ![urbanspaceman](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.electra.one/urbanspaceman/32/206_2.png) [@urbanspaceman](https://forum.electra.one/u/urbanspaceman)\
**Post date:** [April 29, 2023, 2:39pm UTC](https://forum.electra.one/t/getmessage-function-not-working-in-3-1/2036/2 "2023-04-29T14:39:28Z")

</div>

Apologies, I guess we talked about this recently and I forgot:

> [@parameterMap.onChange() changed?](https://forum.electra.one/t/parametermap-onchange-changed/1979):
>
> When I tried to use parameterMap.onChange() like the example: function parameterMap.onChange(valueObjects, origin, midiValue) print (string.format ("a new midiValue %d from origin %d", midiValue, origin)) for i, valueObject in ipairs (valueObjects) do \*\*local control = valueObject:getControl ()\*\* print (string.format ("affects control value %s.%s", control:getName (), valueObject:getId ())) end end and I turn a control, I get…

---

<div class="post-metadata">

**Author:** ![martin](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.electra.one/martin/32/145_2.png) [@martin](https://forum.electra.one/u/martin)\
**Post date:** [May 16, 2023, 7:01am UTC](https://forum.electra.one/t/getmessage-function-not-working-in-3-1/2036/3 "2023-05-16T07:01:48Z")

</div>

> [@urbanspaceman](#):
>
> ```auto
> function parameterMap.onChange (valueObjects, origin, value)
> local paramNum = valueObjects[1]:getMessage():getParameterNumber()
> end
> 
> ```

I tested this one and I can get information out of the Message object just fine now.

---

<div class="post-metadata">

**Author:** ![urbanspaceman](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.electra.one/urbanspaceman/32/206_2.png) [@urbanspaceman](https://forum.electra.one/u/urbanspaceman)\
**Post date:** [May 16, 2023, 8:54am UTC](https://forum.electra.one/t/getmessage-function-not-working-in-3-1/2036/4 "2023-05-16T08:54:20Z")

</div>

I ran into this because I rolled back from 3.1.7 to 3.1 to get past the envelopes freezing, so I did get stuck between 2 versions that had different bugs.
