I am using a script on a button actionPerformed to submit change modifications to a change log. When I run it in the vision client launcher, I keep getting errors. Does anyone know a solution to this issue?
These are my versions of Ignition and Java:
Ignition v8.1.7 (b2021060314)
Java: Azul Systems, Inc. 11.0.11
Button Script:
# This script was generated automatically by the update query
# script builder. You may modify this script, but if you do,
# you will not be able to use the update query builder to update
# this script without overwriting your changes.
#ID of request pulled from change request text field. That field is autopopulated with the next highest available ID number
id = event.source.parent.getComponent('Change Request ID Text Field').intValue
#request date pulls current time on server
reqDate = system.date.now()
#impDate set by user
impDate = event.source.parent.getComponent('Date Implemented Cal').date
#user selected temporary change
temp = event.source.parent.getComponent('Temp Change CheckBox').selected
#if change is temporary use user selected data. if not temporary, value null
if temp == 1:
revDate = event.source.parent.getComponent('Date Reverted Cal').date
else:
revDate = None
#set initial status to implemented unless already reverted temporary change
if temp == 1 and revDate < reqDate:
status = "Reverted"
else:
status = "Implemented"
#initiator autofills with active user but can be changed - text field
initiator = event.source.parent.getComponent('Initiator Text Field').text
#department will determine who approves/gets notified - dropdown
department = event.source.parent.getComponent('Department Dropdown').selectedLabel
#available areas determined by department selection - dropdown
area = event.source.parent.getComponent('Area Dropdown').selectedLabel
#description of the change made - text area
description = event.source.parent.getComponent('Description Text Area').text
#justification for change being made - text area
justification = event.source.parent.getComponent('Justification Text Area').text
#SOP change? -checkbox
sop = event.source.parent.getComponent('SOP CheckBox').selected
#recipe/raw material change - checkbox
recipe = event.source.parent.getComponent('Recipe CheckBox').selected
#process parameter change - checkbox
parameter = event.source.parent.getComponent('Parameter Checkbox').selected
#physical equipment mod - checkbox
physical = event.source.parent.getComponent('Equipment Checkbox').selected
#change impacting occupational safety - checkbox
ocSafe = event.source.parent.getComponent('OcSafety Checkbox').selected
#change to chemical type or handling - checkbox
chem = event.source.parent.getComponent('Chemical Check Box').selected
#programming change/HMI change/sensor change - checkbox
automation = event.source.parent.getComponent('Automation Checkbox').selected
#does the change bypass a safety function/protocol - checkbox
safetyBypass = event.source.parent.getComponent('Safety Bypass Checkbox').selected
system.nav.closeParentWindow(event)
##conditions requiring production approval
#if sop == 1 or recipe == 1 or parameter == 1 or physical == 1 or chem == 1 or automation == 1 or ocSafe == 1 or safetyBypass == 1:
# productionreq = 1
#else:
# productionreq = 0
#
##conditions requiring safety approval
#if chem == 1 or ocSafe == 1 or safetyBypass == 1:
# safetyreq = 1
#else: safetyreq = 0
#
##conditions requiring engineering approval
#if recipe == 1 or parameter == 1 or physical == 1 or chem == 1 or automation == 1 or safetyBypass == 1:
# engineeringreq = 1
#else:
# engineeringreq = 0
#
##conditions requiring quality notification
#if recipe == 1:
# qualitynote = 1
#else:
# qualitynote = 0
#
##conditions requiring maintenance notification
#maintenancenote = 1
prodApprover = "test"
prodDate = system.date.now()
engrApprover = "test"
engrDate = system.date.now()
safeApprover = "test"
safeDate = system.date.now()
finalApproval = 0
finalDate = system.date.now()
system.db.runNamedQuery("UpdateChangeRequest", {"RequestStatus":status, "DateImplemented":impDate, "Temporary":temp, "DateReverted":revDate, "Initiator":initiator,
"Department":department, "Area":area, "Description":description, "Justification":justification, "SOP":sop , "Recipe":recipe, "Parameter":parameter, "Physical":physical,
"OcSafety":ocSafe,"SafetyBypass":safetyBypass,"Chemical":chem ,"Automation":automation, "ApproverProd":prodApprover,"ApproverProdDate":prodDate,"ApproverEngr":engrApprover,
"ApproverEngrDate":engrDate,"ApproverSafe":safeApprover,"ApproverSafeDate":safeDate,"ApprovalFinal":finalApproval, "DateApproved":finalDate,"ChangeReq":id})
##creates email address of initiator
initiatorEmail = initiator + "@stonebrewing.com"
##sets up list for the notification report to go out to
distribution = [initiatorEmail]
#adds production notification to the list dependent on what department was selected
if productionreq == 1 and department == "Brewing":
distribution.append("nicole.williams@stonebrewing.com")
elif productionreq == 1 and department == "Packaging":
distribution.append("nicole.williams@stonebrewing.com")
elif productionreq == 1 and department == "Water Rec":
distribution.append("nicole.williams@stonebrewing.com")
elif productionreq == 1 and department == "Escondido Production":
distribution.append("nicole.williams@stonebrewing.com")
#adds other relevant notifications to the distribution list
if engineeringreq == 1:
distribution.append("nicole.williams@stonebrewing.com")
if safetyreq == 1:
distribution.append("nicole.williams@stonebrewing.com")
if qualitynote == 1:
distribution.append("nicole.williams@stonebrewing.com")
if maintenancenote == 1:
distribution.append("nicole.williams@stonebrewing.com")
#establishes email contents
emailSubject = "Change Notification #" + str(id)
emailBody = "User: " + initiator + " <br/> " + "Department: " + department + " <br/> " + "Area: " + area + " <br/> " + "Description: " + description
emailSettings = {"to":distribution, "smtpServerName":"StoneEmail", "from":"ignition_alerts@stonebrewing.com", "subject":emailSubject, "body":emailBody}
#emails out the report
reportParameters = {"changeid":str(id),"initiator":initiator,"date":impDate,"temporary":temp,"department":department,"area":area,"description":description,"justification":justification,
"sop":sop,"recipe":recipe,"parameter":parameter,"physical":physical,"ocsafety":ocSafe,"chemicals":chem,"automation":automation,"safetybypass":safetyBypass}
system.report.executeAndDistribute(path="Change Notification", project="HMI", parameters = reportParameters, action= "email",
actionSettings = emailSettings)
#system.db.refresh(event.source.parent.getComponent('Power Table'),"data")
Error thread:
Traceback (most recent call last):
File "<event:actionPerformed>", line 25, in <module>
java.lang.NullPointerException
at java.base/java.util.Date.getMillisOf(Unknown Source)
at java.base/java.util.Date.compareTo(Unknown Source)
at java.base/java.util.Date.compareTo(Unknown Source)
at org.python.core.PyJavaType$ComparableMethod.__call__(PyJavaType.java:916)
at org.python.core.PyObjectDerived.__gt__(PyObjectDerived.java:560)
at org.python.core.PyObject._lt(PyObject.java:1648)
at org.python.pycode._pyx16.f$0(<event:actionPerformed>:147)
at org.python.pycode._pyx16.call_function(<event:actionPerformed>)
at org.python.core.PyTableCode.call(PyTableCode.java:171)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1614)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:799)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:206)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:297)
at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:57)
at com.sun.proxy.$Proxy45.actionPerformed(Unknown Source)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.desktop/java.awt.Component.processEvent(Unknown Source)
at java.desktop/java.awt.Container.processEvent(Unknown Source)
at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
java.lang.NullPointerException: java.lang.NullPointerException
at org.python.core.Py.JavaError(Py.java:552)
at org.python.core.PyTableCode.call(PyTableCode.java:180)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1614)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:799)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:206)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:297)
at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:57)
at com.sun.proxy.$Proxy45.actionPerformed(Unknown Source)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.desktop/java.awt.Component.processEvent(Unknown Source)
at java.desktop/java.awt.Container.processEvent(Unknown Source)
at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at java.base/java.util.Date.getMillisOf(Unknown Source)
at java.base/java.util.Date.compareTo(Unknown Source)
at java.base/java.util.Date.compareTo(Unknown Source)
at org.python.core.PyJavaType$ComparableMethod.__call__(PyJavaType.java:916)
at org.python.core.PyObjectDerived.__gt__(PyObjectDerived.java:560)
at org.python.core.PyObject._lt(PyObject.java:1648)
at org.python.pycode._pyx16.f$0(<event:actionPerformed>:147)
at org.python.pycode._pyx16.call_function(<event:actionPerformed>)
at org.python.core.PyTableCode.call(PyTableCode.java:171)
... 42 more
Ignition v8.1.7 (b2021060314)
Java: Azul Systems, Inc. 11.0.11