Hello all,
I am using the following script to write to sql table the data from few dropdown boxes. But if the selected value is blank it won’t write it down as NULL. Any idea how to do that? Here is the code:
[code]name = system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 8’).selectedStringValue
department = system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 9’).selectedStringValue
factory = system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown’).selectedStringValue
offices = system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 1’).selectedStringValue
type = system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 2’).selectedStringValue
ppe = system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 3’).selectedStringValue
risks = system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 4’).selectedStringValue
housekeeping = system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 5’).selectedStringValue
tools = system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 6’).selectedStringValue
equipment = system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 7’).selectedStringValue
comments = system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Text Area’).text
date = system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Popup Calendar’).date
date2=system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Popup Calendar’).datetostring
a=system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown’).selectedStringValue
b=system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 1’).selectedStringValue
c=system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 2’).selectedStringValue
d=system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 3’).selectedStringValue
e=system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 4’).selectedStringValue
f=system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 5’).selectedStringValue
g=system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 6’).selectedStringValue
h=system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 7’).selectedStringValue
i=system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 8’).selectedStringValue
j=system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 9’).selectedStringValue
k=event.source.parent.getComponent(‘Text Area’).text
if (a == “” and b == “” and c == “” and d == “” and e == “” and f == “” and g == “” and h == “” and i == “” and j == “” and k == “”):
system.gui.messageBox(“Fill in the form first!”)
else:
insertQuery = “”“INSERT INTO [%s] ([Correction Action],[Department],[Date],[General Risks],[Good Housekeeping],[Location Factory Focus],[Location Offices & others],[Name],[PPE],[Safe Equipment],[Tools and Equipment],[Type])
VALUES (’%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’,’%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’)”"" % (‘SUBO’, comments,department,date2,risks,housekeeping,factory,offices,name,ppe,equipment,tools,type)
system.db.runPrepUpdate(insertQuery)
system.gui.messageBox(“Your SUBO was added!”)
system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown’).selectedStringValue = None
system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 1’).selectedStringValue = None
system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 2’).selectedStringValue = None
system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 3’).selectedStringValue = None
system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 4’).selectedStringValue = None
system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 5’).selectedStringValue = None
system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 6’).selectedStringValue = None
system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 7’).selectedStringValue = None
system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 8’).selectedStringValue = None
system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Dropdown 9’).selectedStringValue = None
system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Text Area’).text = None[/code]