I have an application running well , when i push a button this copy the values of some field text and number fields in a NamedQuery variables , this values are inserted in a table in a database. to here everything war running fine but , I need automate the same application with a simple script and I observed that is running twice,I did put this script in a transform of a custom variable when this variable change the value to “True” the script transform is executed , I tested in the script console the same script an running only 1 time
Code="+52"
Num=Code+"4420000000" # I replace this number
Name="Alerta App i4.0: "+"Rutina "+" ha iniciado"
Status=0
Params={'Numero':Num,'Texto':Name,'Status':Status}
system.db.runNamedQuery("Twilio/Insert",Params)
Sure.
here´s the custom properties
“URenRutina” is binding with a boolean condition “if robot is running:”
“EnWhats” is a boolean condition if the fields are filled correctly.
ScriptCount: is an integer that I use to find out how many time run the script
Here is the components:
in the binding of “URenRutina” I made this transform script
def transform(self, value, quality, timestamp):
"""
Transform the incoming value and return a result.
Arguments:
self: A reference to the component this binding is configured on.
value: The incoming value from the binding or the previous transform.
quality: The quality code of the incoming value.
timestamp: The timestamp of the incoming value as a java.util.Date
"""
if self.getChild("root").getChild("CoordinateContainer").getChild("FlexRepeaterAndRoutines").getChild("Routines").getChild("MurrElectronik").getChild("PhotoCell").getChild("ToggleRoutinePhoto").props.selected:
RutinaN="Fotoelectrico en BlockIO Impact 67 Murrelectronik"
if self.getChild("root").getChild("CoordinateContainer").getChild("FlexRepeaterAndRoutines").getChild("Routines").getChild("MurrElectronik").getChild("Inductive").getChild("ToggleRoutineInd").props.selected:
RutinaN="Inductivo en BlockIO Impact67 Murrelectronik"
if self.getChild("root").getChild("CoordinateContainer").getChild("FlexRepeaterAndRoutines").getChild("Routines").getChild("Sick").getChild("Photocell").getChild("RoutineSick").props.selected:
RutinaN="Fotoelectrico en BlockIO SIG200"
if self.getChild("root").getChild("CoordinateContainer").getChild("FlexRepeaterAndRoutines").getChild("Routines").getChild("Coretigo").getChild("Encoder").getChild("Encoder_0").props.selected:
RutinaN="Encoder en BlockIO Coretigo"
if self.getChild("root").getChild("CoordinateContainer").getChild("FlexRepeaterAndRoutines").getChild("Routines").getChild("Coretigo").getChild("Inductive").getChild("Inductive Rob").props.selected:
RutinaN="Inductivo en BlockIO Coretigo"
if self.getChild("root").getChild("CoordinateContainer").getChild("FlexRepeaterAndRoutines").getChild("Routines").getChild("Opto").getChild("Buttons").getChild("ToggleSwitch_4").props.selected:
RutinaN="Pulsar botones en Opto 22"
if value and self.custom.EnWhats:
Code=self.getChild("root").getChild("CoordinateContainer").getChild("FlexRepeaterAndRoutines").getChild("Routines").getChild("Messages").getChild("FixTemplate").getChild("Number").getChild("Dropdown").props.value
Num=Code+str(self.getChild("root").getChild("CoordinateContainer").getChild("FlexRepeaterAndRoutines").getChild("Routines").getChild("Messages").getChild("FixTemplate").getChild("Number").getChild("NumericEntryField").props.value)
Name="Alerta App i4.0: "+"Rutina "+RutinaN+" ha iniciado"
Status=0
Params={'Numero':Num,'Texto':Name,'Status':Status}
system.db.runNamedQuery("Twilio/Insert",Params)
self.custom.ScriptCount=self.custom.ScriptCount+1
return value
the last code related to variables of my application but if I make a change for a fixed number and text (next code)the result is the same , in the table receive 2 rows with the same data and the custom property “ScriptCount” value get moving 2,4,6 …
if I run this code in the Script Console this only run one time. the row 251 did run in the script console
and the next 252,253,524,255 was running in with the transform script
Verify you haven’t replicated that code to run in multiple places. Some users will often configure scripts in one Action and then realize later on that the script should be in a different Action - but they often forget to remove the original implementation. Use the Find/Replace tool to search for your “Alerta App i4.0” text and see if it is in place somewhere else.
Show us the full binding, instead of just the transform; there’s a very real possibility your binding is causing this issue instead of the transform.
I create other new project and run this script when a memory boolean tag change his value and de behavior is the same, i remember a post with a similar issue and the solution it was restart the gateway. SimilarIssue
But you still need to check that current value is True.
Edit: Nvm, @lrose was correct.
How strange, my tests failed with the same error, but only the first time after making a change to the script. All tests after the first worked fine. A bug maybe?
following the test with the console I found a difference the same script ,I paste the same code in a event of button and observe the console just 1 register and only 1 register in the DB.
this is the test with the code in a event in a button
I would think this would do the trick, it looks like the quality is causing the tag change event to fire. Also it may be time to contact support, if you can let them see your project live they may have a better time helping.