# messageHandler question on formatting for parameters

**URL:** <https://forum.inductiveautomation.com/t/messagehandler-question-on-formatting-for-parameters/96387>\
**Category:** Ignition\
**Created:** [September 24, 2024, 4:36pm UTC](https://forum.inductiveautomation.com/t/messagehandler-question-on-formatting-for-parameters/96387 "2024-09-24T16:36:06Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zach\_Larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zach_larson/32/54388_2.png) [@Zach\_Larson](https://forum.inductiveautomation.com/u/Zach_Larson)\
**Post date:** [September 24, 2024, 4:36pm UTC](https://forum.inductiveautomation.com/t/messagehandler-question-on-formatting-for-parameters/96387/1 "2024-09-24T16:36:06Z")

</div>

`system.util.sendMessage(messageHandler="myMessageHandler", payload =myDictionary, scope="S")`

I have a message handler called above with the dictionary defined above it.  
However, I am having an issue getting the reception.

Seems like it only messes up when I try to add a payload or try to set the parameters by name.

The handler works if I try this:  
`system.util.sendMessage('myMessageHandler')`

What is the proper way to configure the parameters for the send?  
I think my send is not working.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 24, 2024, 4:39pm UTC](https://forum.inductiveautomation.com/t/messagehandler-question-on-formatting-for-parameters/96387/2 "2024-09-24T16:39:58Z")

</div>

Define "messes up". What happens ?

Also, according to the docs, the syntax is `system.util.sendMessage(projectName, messageHandler, ...)`.  
The first 2 parameters are not marked as optional, so try putting them in.

---

<div class="post-metadata">

**Author:** ![nicoli.liedtke](https://avatars.discourse-cdn.com/v4/letter/n/ee59a6/32.png) [@nicoli.liedtke](https://forum.inductiveautomation.com/u/nicoli.liedtke)\
**Post date:** [September 24, 2024, 4:46pm UTC](https://forum.inductiveautomation.com/t/messagehandler-question-on-formatting-for-parameters/96387/3 "2024-09-24T16:46:20Z")

</div>

I would also check the scope is what you expect and want. Does the handler also work if you do:  
`system.util.sendMessage('myMessageHandler', scope="S")`

I have run into issues trying to send messages with payloads of instances of my own custom classes. I would just check that your payload is exactly the data and types you expect.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 24, 2024, 4:54pm UTC](https://forum.inductiveautomation.com/t/messagehandler-question-on-formatting-for-parameters/96387/4 "2024-09-24T16:54:23Z")

</div>

> [@nicoli.liedtke](#):
>
> I have run into issues trying to send messages with payloads of instances of my own custom classes.

That cannot be supported safely for message handlers outside the leaf project that created the custom class instances. There is a real risk of large memory leaks.

---

<div class="post-metadata">

**Author:** ![nicoli.liedtke](https://avatars.discourse-cdn.com/v4/letter/n/ee59a6/32.png) [@nicoli.liedtke](https://forum.inductiveautomation.com/u/nicoli.liedtke)\
**Post date:** [September 24, 2024, 4:58pm UTC](https://forum.inductiveautomation.com/t/messagehandler-question-on-formatting-for-parameters/96387/5 "2024-09-24T16:58:51Z")

</div>

Yeah it made sense I couldn't do this once I figured out it was causing exceptions only when I sent custom class instances.

In our case we broke down our objects into native types and reconstructed the objects on the other side.

---

<div class="post-metadata">

**Author:** ![Zach\_Larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zach_larson/32/54388_2.png) [@Zach\_Larson](https://forum.inductiveautomation.com/u/Zach_Larson)\
**Post date:** [September 24, 2024, 5:33pm UTC](https://forum.inductiveautomation.com/t/messagehandler-question-on-formatting-for-parameters/96387/6 "2024-09-24T17:33:34Z")

</div>

That seems odd to me since using only the name of the message handler works, but I will try again with the project name.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [September 24, 2024, 5:37pm UTC](https://forum.inductiveautomation.com/t/messagehandler-question-on-formatting-for-parameters/96387/7 "2024-09-24T17:37:34Z")

</div>

It seems odd to me that you're saying it works, but it may also have to do with where you are calling it from. Since message handlers are a project resource, I seem to recall there being an undocumented behavior where if it is called from within the containing project then it will still work. Or something along those lines.

Project Name should definitely be included in the call.

---

<div class="post-metadata">

**Author:** ![Zach\_Larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zach_larson/32/54388_2.png) [@Zach\_Larson](https://forum.inductiveautomation.com/u/Zach_Larson)\
**Post date:** [September 24, 2024, 5:43pm UTC](https://forum.inductiveautomation.com/t/messagehandler-question-on-formatting-for-parameters/96387/8 "2024-09-24T17:43:04Z")

</div>

> [@Zach\_Larson](#):
>
> The handler works if I try this:  
> `system.util.sendMessage('myMessageHandler')`

When I press the button with this, I write a variable correctly.

So far every way I write the parameter call though, nothing is called correctly as far as I can tell.

I don't get any errors either.

I am copy pasting the name of the handler.  
When I check other posts though as recent as August, they have `messageType =` instead of `messageHandler =`.

I think I am typing something wrong, scope is wrong, or I have a syntax obstruction that doesn't throw an error.

In my test, I have a view with both the button in one flex container and various labels in other flex containers to see which will write.

Listener is configured for page and view.  
Scope is default.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [September 24, 2024, 5:47pm UTC](https://forum.inductiveautomation.com/t/messagehandler-question-on-formatting-for-parameters/96387/9 "2024-09-24T17:47:43Z")

</div>

Where are you trying to send this message from and to?

`system.util.sendMessage()` and `system.perspective.sendMessage()` are different functions with different signatures and purposes.

---

<div class="post-metadata">

**Author:** ![Zach\_Larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zach_larson/32/54388_2.png) [@Zach\_Larson](https://forum.inductiveautomation.com/u/Zach_Larson)\
**Post date:** [September 24, 2024, 5:55pm UTC](https://forum.inductiveautomation.com/t/messagehandler-question-on-formatting-for-parameters/96387/10 "2024-09-24T17:55:54Z")

</div>

Thanks so much
