How to path to from a button in one view to an object in another view?

I am currently setting up a data entry form with a Button that takes that entered data, queries some data from our db, and does some calculations and formatting. All this data is used to schedule an event on an equipment schedule, but the problem is that in order to use "scheduledEvents.append(item)" method, I need to get the path from the view where the button is located to the view where the equipment schedule is. I have tried to use "self.parent" with multiple parents, but that only seems to work for objects in the same view.
Is there a way to write a generic path to an object in another view that doesn't start with "self" in the button event script?

I have been using these posts for reference:
(1) Scripting Perspective to add events for Equipment Schedule - Ignition - Inductive Automation Forum

(2) Perspective - Equipment Schedule Scripting - Ignition User Manual 8.1 - Ignition Documentation (inductiveautomation.com)

My goal is that anyone can open a perspective session and easily schedule an event that would update on all sessions. Also if it helps the general structure is that under "Views" I have two folders and in each of those folders there is a view that contains one of the objects:

Views>folder_1>view_1>root>equipmentSchedule
Views>folder_2>view_2>root>button

Psst.. Use a Perspective Message Handler instead! Create a message handler on the Equipment Schedule component (or the root container of the view the Equipment Schedule component is in or whatever you choose), and then call it from your other views, popups, etc. It makes it much easier to deal with.

EDIT: I gave a generic answer on how to accomplish what you're trying to do, but @Transistor gave the better answer to the actual problem you'll face - even if you can send a message and add an item using a message handler, those new schedule events you add in the session will not persist (i.e. they aren't getting saved anywhere). Use a database or tag(s) if you must.

2 Likes

That's what Message Handlers are for, but they can only work if the other view is open and you can't guarantee that with your project configuration (unless the data entry form is a modal popup from the view being modified).

https://docs.inductiveautomation.com/display/DOC81/Component+Message+Handlers

Instead, you should be writing to the data source. Then bind the Equipment Schedule component's items property to that datasource. Use the message handler to trigger a refresh on the items property (which will work if the view is open) and if the view is not open it will reload the data via the binding on load.

2 Likes

Just to be clear: you cannot use the approach in your question, as Perspective views are strictly isolated from each other. They cannot reference components outside their own view. (This is one of the major differences between Vision and Perspective, FWIW. Vision client scripts have full access to the entire Java Swing environment.)

1 Like