# Checkbox enabled

**URL:** <https://forum.inductiveautomation.com/t/checkbox-enabled/67993>\
**Category:** Ignition\
**Created:** [December 27, 2022, 9:31am UTC](https://forum.inductiveautomation.com/t/checkbox-enabled/67993 "2022-12-27T09:31:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![KEERTHANA\_HEMANTH](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/keerthana_hemanth/32/42024_2.png) [@KEERTHANA\_HEMANTH](https://forum.inductiveautomation.com/u/KEERTHANA_HEMANTH)\
**Post date:** [December 27, 2022, 9:31am UTC](https://forum.inductiveautomation.com/t/checkbox-enabled/67993/1 "2022-12-27T09:31:15Z")

</div>

I have a checkbox for each day of the week. I need to log the selected day name to my database  
when the checkbox is enabled and the ticket is created by clicking on create ticket button . How to proceed with this.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/7/f70ec613d5672cd765dc4475eb3629f7d7c8605d.png)

---

<div class="post-metadata">

**Author:** ![Matthew\_Hunt](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@Matthew\_Hunt](https://forum.inductiveautomation.com/u/Matthew_Hunt)\
**Post date:** [December 27, 2022, 9:41am UTC](https://forum.inductiveautomation.com/t/checkbox-enabled/67993/2 "2022-12-27T09:41:02Z")

</div>

I would create a Named Query that collects the data in the fields and puts it in the database whenever you click the Create Ticket button.

on the Create Ticket button you can use an "onActionPerformed" event and use the system.db.runNamedQuery() function to log the data into the Database.  
You can define the entire dataset of your named query within the runNamedQuery function.

Depending on how the data in the DB needs to be structured there are quite a few ways of solving this, but you will most likely have to do something within a script action like retrieving the properties of the fields and checkboxes.

---

<div class="post-metadata">

**Author:** ![KEERTHANA\_HEMANTH](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/keerthana_hemanth/32/42024_2.png) [@KEERTHANA\_HEMANTH](https://forum.inductiveautomation.com/u/KEERTHANA_HEMANTH)\
**Post date:** [December 27, 2022, 9:49am UTC](https://forum.inductiveautomation.com/t/checkbox-enabled/67993/3 "2022-12-27T09:49:37Z")

</div>

I Have created a script for my create ticket button which is able to read all other components value.  
I want to know how to read the label of the checkbox only when enabled so that I can pass that value to the database table create

Here is the script linked to the create ticket button

def runAction(self, event):

```
Site=self.parent.parent.getChild("FlexContainer").getChild("FlexContainer_0").getChild("FlexContainer_3").getChild("site").props.value
AssetID=self.parent.parent.getChild("FlexContainer").getChild("FlexContainer_1").getChild("FlexContainer_1").getChild("FlexContainer_1").getChild("Assetid").props.value
ResponsiblePerson =self.parent.parent.getChild("FlexContainer").getChild("FlexContainer_1").getChild("FlexContainer_2").getChild("FlexContainer_2").getChild("ResponsiblePerson").props.value
ReportedBy =self.parent.parent.getChild("FlexContainer").getChild("FlexContainer_1").getChild("FlexContainer_2").getChild("FlexContainer").getChild("ReportedBy").props.value
Observation =self.parent.parent.getChild("FlexContainer").getChild("FlexContainer_3").getChild("Description").props.text
ticketStatus = "OPEN"
MONDAY=self.parent.parent.getChild("FlexContainer").getChild("FlexContainer_1").getChild("FlexContainer_1").getChild("FlexContainer_4").getChild("ToggleSwitch").props.select

if AssetID != '' and ResponsiblePerson != '' and ReportedBy != '' and Observation != '' and dayselection !='' and Site !='':
    system.db.runNamedQuery("CMMS/SCHEDULE_MASTER/insert_weekly_SCTK", {"ASSET_ID": AssetID, "RESPONSIBLE_PERSON": ResponsiblePerson, "REPORTED_BY": ReportedBy, "OBSERVATION": Observation, "TICKET_STATUS": ticketStatus , "DAY_SELECTION": dayselection,"SITE_NAME": Site})
    system.perspective.openPopup('errorMessage','Templates/General/messageBox',params = {'Text':'Weekly Schedule Maintainance Ticket Sucessfully Created'},modal=True,showCloseIcon=False,viewportBound=True)
    system.perspective.sendMessage('refresh',scope = 'page')
    system.perspective.closePopup('addNewTicket')
    system.db.refresh(event.source.parent.getComponent('Power Table'), "data")
	
else:
	system.perspective.openPopup('errorMessage','Templates/General/messageBox',params = {'Text':'Enter all the fields!'},modal=True,showCloseIcon=False,viewportBound=True)

```

---

<div class="post-metadata">

**Author:** ![Matthew\_Hunt](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@Matthew\_Hunt](https://forum.inductiveautomation.com/u/Matthew_Hunt)\
**Post date:** [December 27, 2022, 9:58am UTC](https://forum.inductiveautomation.com/t/checkbox-enabled/67993/4 "2022-12-27T09:58:19Z")

</div>

Here is a small example of how you could solve it.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/e/5e27610af43a851d8ab7c5bb6d69cc10e4fe59f0.png)

Here it checks if the check is toggled or not and only passes the label to the parameter if it is checked.  
If you have a check for each day you just need to create some sort of logic to check all of the boxes if they are toggled or not.

Note that all the properties of all components are reachable through scripts so you can use conditional statements for every prop on every component if you need

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [December 27, 2022, 10:02am UTC](https://forum.inductiveautomation.com/t/checkbox-enabled/67993/5 "2022-12-27T10:02:52Z")

</div>

There is no checkbox component in your screenshot. Do you mean the "toggle switch"?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [December 27, 2022, 10:47am UTC](https://forum.inductiveautomation.com/t/checkbox-enabled/67993/6 "2022-12-27T10:47:01Z")

</div>

Tips:

Use the \</\> code formatting button to preserve code indentation and apply syntax highlighting in your posts. (Select the code and then click the button.) It's essential for Python and makes any code much easier to read. There's an edit button 🖉 below your post so you can fix it.

You can simplify the management of reading component values by binding each component's value to a custom property of the view.  
For example, instead of

```auto
Site = self.parent.parent.getChild("FlexContainer").getChild("FlexContainer_0")
    .getChild("FlexContainer_3").getChild("site").props.value

```

create `props.custom.Site` and bind the site dropdown's value property to that. Now your code becomes,  
`Site = view.custom.Site`  
This is far easier to read and maintain and means that the code won't break if the view layout is changed or you have to move components in or out of containers.

---

<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:** [December 27, 2022, 8:08pm UTC](https://forum.inductiveautomation.com/t/checkbox-enabled/67993/7 "2022-12-27T20:08:50Z")

</div>

> [@Transistor](#):
>
> You can simplify the management of reading component values by binding each component's value to a custom property of the view

I was about to say the same thing.  
But just to make something clear, only bind **up** as @Transistor has, not down.  
As in, bind child props to parent props; don't bind parent props to child props, otherwise things get messy

---

<div class="post-metadata">

**Author:** ![KEERTHANA\_HEMANTH](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/keerthana_hemanth/32/42024_2.png) [@KEERTHANA\_HEMANTH](https://forum.inductiveautomation.com/u/KEERTHANA_HEMANTH)\
**Post date:** [January 6, 2023, 3:56am UTC](https://forum.inductiveautomation.com/t/checkbox-enabled/67993/8 "2023-01-06T03:56:15Z")

</div>

Thank you everyone for the help. I was able to resolve my issue.
