I’m new in Ignition and i want to refresh a table in a project called “A” by a message handler sent by project “B”.
i tried this :
system.util.sendMessage(project=“A”,messageHandler = “Refresh_Table”)
and in my table component in project “A” i have the message handler called “Refresh_Table”
Gateway script MessageHandlerException, project ‘Lampes’, message handler ‘Refresh_Table’: com.inductiveautomation.ignition.common.script.message.MessageHandlerException: The message handler “Refresh_Table” could not be found! Check your event script message handlers.
As I can see, you are using system.util.sendMessage function, wich only works if the Message Handler is configured either on Client / Gateway / Session Event Scripts.
A Message Handler defined in a perspective component must be called with the function system.perspective.sendMessage. This functions only works is the call and the handler are in the same project.
So, in your case, you must move the message handler defined in the component to a message handler defined in Session event scripts.
Thank a lot for your support, i really appreciate it!
so, In my project A (Where I want to refresh my table ) I have to create a Session Message Handlers (“Refresh_TableSession”) where i’ll use system.perspective.sendMessage(“Refresh_Table”).
In my table (in project A) i have to configure script and add the message Handlers “Refresh_Table” with my script.
and in project B i only need to use system.util.sendMessage(project=“A”, messageHandler= “Refresh_TableSession”)
One additional thing to note is that you should probably set the “Scope” argument for system.util.sendMessage(). If you don’t then it will send to all the scopes which will throw that MessageHandlerException you were seeing when it tries to find a message handler in a scope it doesn’t exist in. From what I can tell in your use case, you’ll want to set it to “S” for session so that it only sends it to session message handlers.
it looks like it can find the MessageHandler now.
However, my script is not running on my table component the table is not refreshing, and i have a warning with the following comments : " no perspective page attached to this thread "
should i need to provide a pageID or something like that somewhere ?
Seems like a bug to me but not certain. The perspective module doesn’t seem accessible from the session event scripts (ctrl+space not working for system.perspective ).
It depends on where you’re calling the script from.
Could you please provide:
the exact code you’re executing and clearly define which area that code is in
your current version
The error you’re seeing is typically encountered when a .perspective package function is invoked in an area of the application which does not have a Perspective context. I would expect to see that error if you’re invoking system.perspective package functions in a Gateway context outside of a Perspective area.
OR
You might not be supplying the correct scope; if you don’t specify “session”, then the function uses the “page” scope, which requires you also supply the pageId and which would then require access to the Perspective page thread.
No, you do want to use the "S" for Session scope. Your issue is that your Projects > Session Event call of sendMessage does not provide a scope. Change the Project > Session Event to be this:
If you don't specify the scope as being "session", then the function defaults to the "page" scope, which requires that you either invoke the function from a Perspective Page, or that you supply a pageId argument.