Perspective - Scripting - Binding - Firing issue

I’m on 8.1.11

I have some cascading views with flexRepeater to group my data.

I have binding with multiple expressions and my problem is that my script fire at each expression change and I want that my script run only once when all values are received for each expression, i have checked the “wait on all” but I can’t figure out how confirm when script can run.

image

To get the PROGRAM_GROUP / PROGRAMS running only once I have added a “flag” to exit id script is currently running.
image

	myInstances = self.props.instances
	
	if not value["can_run"]:
		return myInstances
		
	system.perspective.print("GROUP_PROGRAM / PROGRAMS: " + str(value["payload"]["programs"]))
	instances = []
		
	if value["payload"] is None or str(value["payload"]) == "{}":
		return instances
	
	payload = value["payload"]
			
	if payload["programs"] is None or payload["programs"] == "" or payload["orders"] is None or str(payload["orders"]) == "":
		return instances
	
	db_name = "bosello"
	db_available = _Functions.dbIsAvailable(db_name)  #Valid if database is available
	if not db_available:
		return 
	
	for program in payload["programs"]:
		query = "SELECT TCastings.WorkingProgramName, MAX(TCastings.TotalViewNumber) as nbViews FROM TCastings WHERE TCastings.WorkingProgram=" + str(program) + " "
		if not "all" in str(payload["orders"]) and not payload["orders"] is None and not str(payload["orders"]) == "":
			query_order = ""
			for order in payload["orders"]:
				query_order += (" OR " if not query_order == "" else "") + "SerialNumber='" + str(order) + "'"
			query += ("WHERE (" if not "WHERE" in query else "AND (") + query_order + ") "
	
		if not payload["date_from"] is None and not payload["date_from"] == "":
			myDate = payload["date_from"]
			query += ("WHERE (" if not "WHERE" in query else "AND (") + "TCastings.Date >='" + myDate + "') "
		if not payload["date_to"] is None and not payload["date_to"] == "":
			myDate = payload["date_to"]
			query += ("WHERE (" if not "WHERE" in query else "AND (") + "TCastings.Date <='" + myDate + "') "	
		query += "AND NOT TCastings.SerialNumber='0 ' "#AND NOT TCastings.SerialNumber IS NULL AND NOT TCastings.SerialNumber='' "
		query += "GROUP BY WorkingProgramName, TotalViewNumber "
		query += "ORDER BY WorkingProgramName DESC"
		
		prog_used = system.db.runQuery(query, db_name)
		
		if len(prog_used) > 0:
			myDict = {}
			myDict["working_program"] = program
			myDict["working_program_name"] = prog_used[0]["WorkingProgramName"]
			myDict["orders"] = payload["orders"]
			myDict["nb_cells"] = payload["nb_cells"]
			myDict["date_from"] = payload["date_from"]
			myDict["date_to"] = payload["date_to"]
			myDict["defects_only"] = payload["defects_only"]
			myDict["nb_views"] = prog_used[0]["nbViews"]
			
			#IMAGES_HOT_SPOT
			images_data = []
			for i in range(prog_used[0]["nbViews"]):		
				query = "SELECT TCastings.WorkingProgram, TCastings.SerialNumber, TCastings_1.Progressive, TCastings_1.Date, TCastings_1.Accepted as InjAccepted, TDefects.* "
				query += "FROM TCastings "
				query += "INNER JOIN TCastings AS TCastings_1 ON TCastings.Date = TCastings_1.Date INNER JOIN TDefects ON TCastings.Progressive = TDefects.CastingProgressive "
				query += "WHERE TCastings.WorkingProgram=" + str(program) + " AND TDefects.[View]=" + str(i+1) + " "
				
				if not "all" in str(payload["orders"]) and not payload["orders"] is None and not payload["orders"] == "":
					query_orders = ""
					for order in payload["orders"]:
						query_orders += ("OR " if not query_orders == "" else "") + "TCastings.SerialNumber='" + str(order) + "'"
					query += "AND (" + query_orders + ") " 
			
				if not payload["date_from"] is None and not payload["date_from"] == "":
					query += "AND TCastings.Date >='" + payload["date_from"] + "' "
				if not payload["date_to"] is None and not payload["date_to"] == "":
					query += "AND TCastings.Date <='" + payload["date_to"] + "' "
				query += "ORDER BY TCastings_1.Date DESC, TCastings_1.Progressive ASC"
				data = system.db.runQuery(query, db_name)
				images_data.append(data)
			myDict["images_data"] = images_data
			instances.append(myDict) 
	self.custom.can_run = False
	return instances

GROUP_ORDER is executed 7x, the only good one is the one with the program 4
image

system.perspective.print("GROUP_ORDER / PROGRAM: " + str(value["program"]))
	
	if value["program"] is None or value["program"] == "" or value["orders"] is None or str(value["orders"]) == "":
		return []
		
	db_name = "bosello"
	db_available = _Functions.dbIsAvailable(db_name)  #Valid if database is available
	if not db_available:
		return []#"db not available"
		
	instances = []
	#try:
	query = "SELECT DISTINCT TCastings.WorkingProgram, TCastings.WorkingProgramName, TCastings.SerialNumber FROM TCastings "
	if not "all" in str(value["program"]):
		query += "WHERE TCastings.WorkingProgram=" + str(value["program"]) + " "
	if not "all" in str(value["orders"]):
		query_order = ""
		for order in value["orders"]:
			query_order += (" OR " if not query_order == "" else "") + "SerialNumber='" + str(order) + "'"
		query += ("WHERE (" if not "WHERE" in query else "AND (") + query_order + ") "
	if not value["date_from"] is None and not value["date_from"] == "":
		myDate = value["date_from"]
		query += ("WHERE (" if not "WHERE" in query else "AND (") + "TCastings.Date >='" + myDate + "') "
	if not value["date_to"] is None and not value["date_to"] == "":
		myDate = value["date_to"]
		query += ("WHERE (" if not "WHERE" in query else "AND (") + "TCastings.Date <='" + myDate + "') "	
	query += "AND NOT TCastings.SerialNumber='0' "#AND NOT TCastings.SerialNumber IS NULL AND NOT TCastings.SerialNumber='' "
	query += "ORDER BY TCastings.WorkingProgramName ASC, TCastings.SerialNumber DESC"
	
	data_group = system.db.runQuery(query, db_name)
	
	for i in range(len(data_group)):
		my_dict={}
		my_dict["item_id"] = i
		my_dict["order"] = str(data_group[i]["SerialNumber"])
		my_dict["program"] = str(data_group[i]["WorkingProgram"])
		my_dict["enabled"] = True
		my_dict["nb_cells"] = value["nb_cells"]
		my_dict["defects_only"] = value["defects_only"]
		my_dict["instances_view_name"] = self.meta.name
		my_dict["date_from"] = value["date_from"]
		my_dict["date_to"] = value["date_to"]
		instances.append(my_dict)
	
	return instances

IMAGES_HOT_SPOT must be executed only once.
image

system.perspective.print("IMAGES_HOT_SPOT")

	
	instances = []

	for i in range(value["nb_views"]):
		my_dict={}
		my_dict["view"] = i+1
		my_dict["program"] = value["program"]
		my_dict["image_data"] = value["images_data"][i]
		instances.append(my_dict)

	return instances

Any helps will be appreciated.

I finally change my approach and now I use sendMessage to pass arguments