Firing script on one component via event change from other components

I have a script which generates a table and who’s conditions are based off of multiple drop-down components. I can get it to work fine via binding the script to a button which fires the script when pushed.

I would very much like to have the script run as soon as a user changes a selection on either of the dropdowns - ie no need for a button. Can someone please explain how this is done? I understand that a change on a dropdown would be fired as an action event or property change event on that component, but how would I get the script - which is on ANOTHER component - to know that a change has happened?

dropdown%20script%20question

You can do this a few ways. You can have your script in the table’s property change script and add a custom properties to the table that looks at each of the drop downs. Then filter your property change script to look at when those custom properties change to run the script. The other option is duplicating the script into property change scripts in all the dropdowns. If you do that I’d put the script in the project scripts and just call it from the dropdowns so you have only have one place you have to edit it instead of in multiple objects.

Is the table based on a SQL Query? What we do normally is add a “whereClause” custom property on the table, an expression, that creates the appropriate where clause based on the dropdowns.

Then the data entry for the table would be something like
SELECT col1, ..., columnN FROM table WHERE {Root Container.Table.whereClause}

Then whenever a dropdown is changed, that whereClause is changed, which automatically trigger’s a requerying of the data.

Wow - I got a response before I even finished editing my post :grinning:

I did think about putting equivalent scripts on each dropdown but that seems clunky and would require more management as things inevitably change over time.

I think your comment about creating a custom property is the way to go here. I will give that a try and report back shortly!

I’ve been flustered about this because this has to be a very common thing to do AND would be hugely powerful. Right now I have functionality it’s not very elegant

Bkarabinchak.psi - I mispoke - I should have said “dataset”. We are not referencing SQL at least in this particular case. I will definitely keep your comments in my knowledgebase for the future. Thanks!

1 Like

Assigning a custom property to the table, then firing a script based off of this did the trick! I’m definitely going to be using this for more than just this screen. Thank you so much! You guys are wizards!