Can I return the action button in triggeredById?

Hi Retool Team,

I would like to know whether I can return the action button in triggeredByID, please.

Situation:

  • I have a table called table1
  • I have two actions in table1, let's call them Button1 and Button2
  • Each action button will trigger two very similar JS queries. So instead of building one JS query for Button1 and another for Button2, I would like to have one JS query and trace whether the query is triggered by Button1 or Button2 via the triggeredById property.
  • However, it seems triggeredById returns only table1 instead of the id of the action button.

Appreciate for a workaround. Thanks!

Screenshot 2021-09-09 at 17.15.10

Hey @oliver.ng!

Great question, at the moment, I believe you would need to create an action for both of these buttons individually. Currently, there is no way to return the name of the specific button that triggered the action (you can use triggeredById which will return the name of the component or i which will return the index of the row that triggered the action). I know we have plans to re-work the table component (along with many other components) and I will make sure to pass this feedback along to my team! In the meantime, would using two separate queries work for your use case here?

hey @Chris-Thompson thanks for getting back. Yep two queries seem to be the workaround at this stage. Looking forward to return the id of the action button some day.

EDIT:
Nevermind. I was able to get this pattern to work in this format:

switch(triggeredById){
  case 'btn_approve': 
    tempState.setIn(["reviewed",table_poi.selectedRow.index],"approved");
    {{table_poi.selectedRow.index + 1}}
    break;
  case 'btn_deny': 
    tempState.setIn(["reviewed",table_poi.selectedRow.index],"denied");
    {{table_poi.selectedRow.index + 1}}
    break;
...etc...

Has any progress been made on this?

Looking to do something like below so I can detect the name of the button and pass that value in in the event handler.

var btn_list = ["btn_approve","btn_deny","btn_poi_exception"];

switch(btn_list.value){
  case triggeredById == 'btn_approve': // if Primary is selected
    tempState.setIn(["reviewed",table_poi.selectedRow.index],"approved");
    {{table_poi.selectedRow.index + 1}}
    break;
  case triggeredById == 'btn_deny': // if Primary is selected
    tempState.setIn(["reviewed",table_poi.selectedRow.index],"denied");
    {{table_poi.selectedRow.index + 1}}
    break;
  case triggeredById == 'btn_poi_exception': // if Primary is selected
    tempState.setIn(["reviewed",table_poi.selectedRow.index],"approved");
    {{table_poi.selectedRow.index + 1}};
}