# Binding API Data to Popup Window

**URL:** <https://forum.inductiveautomation.com/t/binding-api-data-to-popup-window/96460>\
**Category:** Ignition\
**Tags:** perspective, scripting\
**Created:** [September 25, 2024, 8:31pm UTC](https://forum.inductiveautomation.com/t/binding-api-data-to-popup-window/96460 "2024-09-25T20:31:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aisha\_Shiddat](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@Aisha\_Shiddat](https://forum.inductiveautomation.com/u/Aisha_Shiddat)\
**Post date:** [September 25, 2024, 8:31pm UTC](https://forum.inductiveautomation.com/t/binding-api-data-to-popup-window/96460/1 "2024-09-25T20:31:07Z")

</div>

I am trying to bind some api data to a popup view. The view is triggered from an click event when the user selects a row on the table. The information that is returned is based on a PONumber that is passed in as a parameter. Im not able to see any data being passed into the popup view. I created a table in the popup to bind to a view parameter that would pass in the data from the api. I need to click on a row or cell which would capture the PO# in the PoNumber column and pass it into the api call to retrieve data to the view.

[onClickEvent.py](https://forum.inductiveautomation.com/uploads/short-url/1DMVCIWvBxFfu6hauNvJWzfx6jK.py) (541 Bytes)

 ![tableData binding](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/b/fb7488b86f6daf09cf164f89fc08e1ee9ad115fe.png)  
 ![ScrapInspectionView](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/9/19d88a2143dd723781e7e9c9f7eb9cc04147f483.png)

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 25, 2024, 8:55pm UTC](https://forum.inductiveautomation.com/t/binding-api-data-to-popup-window/96460/2 "2024-09-25T20:55:15Z")

</div>

I can't open the py file on my phone, but I would be calling the api from the popup instead. I like to self contain functionality. If you ever wanted to open that popup from somewhere else, you don't want to have to repeat that same script to call the api and then pass it into the popup, you just want to pass the info you've got to the popup, and let the popup retrieve what it needs to from that

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 25, 2024, 9:13pm UTC](https://forum.inductiveautomation.com/t/binding-api-data-to-popup-window/96460/5 "2024-09-25T21:13:14Z")

</div>

Regarding the actual issue with passing in the tableData itself, that looks like it should work to me, assuming your popup has a `params.tableData` prop on its view params

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [September 26, 2024, 4:48am UTC](https://forum.inductiveautomation.com/t/binding-api-data-to-popup-window/96460/6 "2024-09-26T04:48:47Z")

</div>

As @nminchin pointed out you're better off passing the PO number and user ID to the popup as parameters instead. This also allows you to test in the designer easily by setting the parameters to some test values and getting a result.

---

<div class="post-metadata">

**Author:** ![Aisha\_Shiddat](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@Aisha\_Shiddat](https://forum.inductiveautomation.com/u/Aisha_Shiddat)\
**Post date:** [September 26, 2024, 2:16pm UTC](https://forum.inductiveautomation.com/t/binding-api-data-to-popup-window/96460/7 "2024-09-26T14:16:47Z")

</div>

So the script where Im calling my API, I placed it inside of the popup in a script. Would I need to call this script from the click event in the main window. Could you provide an example?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 27, 2024, 5:28am UTC](https://forum.inductiveautomation.com/t/binding-api-data-to-popup-window/96460/8 "2024-09-27T05:28:22Z")

</div>

No, I would add a custom prop bound to the params you pass into the popup using an expression structure binding. When these change, they will trigger the binding to update. Add a script transform to it to perform the API call and return the result.

---

<div class="post-metadata">

**Author:** ![Aisha\_Shiddat](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@Aisha\_Shiddat](https://forum.inductiveautomation.com/u/Aisha_Shiddat)\
**Post date:** [September 30, 2024, 1:57am UTC](https://forum.inductiveautomation.com/t/binding-api-data-to-popup-window/96460/9 "2024-09-30T01:57:18Z")

</div>

Ok you talking about here on the data property of the table that is inside of my popup correct?

 ![TablePropsData 2024-09-29](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/f/7f49767ba36bc813d90351a8fd0d3f7c7bf224c7.png)

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 30, 2024, 1:59am UTC](https://forum.inductiveautomation.com/t/binding-api-data-to-popup-window/96460/10 "2024-09-30T01:59:10Z")

</div>

Yes, that's correct.
