Originally posted as Get a component's id from its event handler - How do I? - Retool Forum
triggeredByIdprovides a string value, but there seems to be no way to dynamically get a reference to the control (as in
triggeredByIdseems to be quite limited in where it's available. Specifically, it's not available in the success/failure part of a query.
- What I'd ideally like to do is be able to set a custom property (call it "tag" or "userInfo" or "context") on a component (e.g.
button1.userInfo = "cancel_emergency"), then be able to look up this value from a query (e.g.
var cmdName = triggeredByComponent.userInfo).
I can work around the first part with
tooltipText and the second part with a component ID to custom value mapping in a temporary state variable, but it would be nicer to do it more directly.