# Save Button to Power Table

**URL:** <https://forum.inductiveautomation.com/t/save-button-to-power-table/87495>\
**Category:** Ignition\
**Tags:** ignition79, vision\
**Created:** [March 18, 2024, 3:36pm UTC](https://forum.inductiveautomation.com/t/save-button-to-power-table/87495 "2024-03-18T15:36:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mia\_Galatis](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@Mia\_Galatis](https://forum.inductiveautomation.com/u/Mia_Galatis)\
**Post date:** [March 18, 2024, 3:36pm UTC](https://forum.inductiveautomation.com/t/save-button-to-power-table/87495/1 "2024-03-18T15:36:12Z")

</div>

Hello! I want users to input three dimensions and have a 'Save' button that will save that information into a power table. I'm not sure how the scripting will work for this. Any help would be appreciated!

Ex. The user will type the width, pitch, and thickness then click on save which will then display and save the values into the power table below.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/7/970b3f466c5d442367c65733d60e070b65287efc.png)

---

<div class="post-metadata">

**Author:** ![Felipe\_CRM](https://avatars.discourse-cdn.com/v4/letter/f/dfb087/32.png) [@Felipe\_CRM](https://forum.inductiveautomation.com/u/Felipe_CRM)\
**Post date:** [March 18, 2024, 3:59pm UTC](https://forum.inductiveautomation.com/t/save-button-to-power-table/87495/2 "2024-03-18T15:59:09Z")

</div>

On the button's actionPerformed event, you'll want to use the [system.dataset.addRow()](https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-dataset/system-dataset-addRow#keywords) function to your dataset. Keep in mind that this will create a whole new dataset (datasets cannot be modified in place) so you'll have to write the result back to your power table's dataset, whether that's a tag or just a bound value.

For a simplified example with only two numeric boxes and a dataset with only width and height:

```auto
width = event.source.parent.getComponent('WidthBox').intValue
height = event.source.parent.getComponent('HeightBox').intValue

current_data = #get your dataset from binding/tag here

new_data = system.dataset.addRow(dataset=current_data, row=[width, height])

#write your new_data to tag/binding here

```

Without more info on where the dataset for the power table comes from I can't really get into more detail

---

<div class="post-metadata">

**Author:** ![Mia\_Galatis](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@Mia\_Galatis](https://forum.inductiveautomation.com/u/Mia_Galatis)\
**Post date:** [March 18, 2024, 5:45pm UTC](https://forum.inductiveautomation.com/t/save-button-to-power-table/87495/3 "2024-03-18T17:45:10Z")

</div>

Could I create a new database and have current\_data = 'New database name'?

I'm not sure what you mean by power table dataset.

---

<div class="post-metadata">

**Author:** ![Felipe\_CRM](https://avatars.discourse-cdn.com/v4/letter/f/dfb087/32.png) [@Felipe\_CRM](https://forum.inductiveautomation.com/u/Felipe_CRM)\
**Post date:** [March 18, 2024, 6:33pm UTC](https://forum.inductiveautomation.com/t/save-button-to-power-table/87495/4 "2024-03-18T18:33:49Z")

</div>

> [@Mia\_Galatis](#):
>
> what you mean by power table dataset.

I mean the Data property on the power table that is bound to whatever data source for your table.

> [@Mia\_Galatis](#):
>
> Could I create a new database

I originally thought you were doing a short-term storage using tags or properties. For storage you can set up a [Named Query](https://docs.inductiveautomation.com/docs/8.1/platform/sql-in-ignition/named-queries) that INSERTs a row into the database and one that SELECTS the table (for binding to your power table)

The script would be pretty different for a database:

```auto
width = event.source.parent.getComponent('WidthBox').intValue
height = event.source.parent.getComponent('HeightBox').intValue

system.db.runNamedQuery(updateMaterials, {"width": width, "height": height})

```

> **[system.db.runNamedQuery | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-db/system-db-runNamedQuery)**
>
> Runs a named query and returns the results.

You can then use a [Named Query Binding](https://docs.inductiveautomation.com/docs/8.1/ignition-modules/vision/binding-types-in-vision/named-query-bindings) to automatically update the power table from the same database.
