palantir-foundryfoundry-slatefoundry-functions

How can I run a Foundry Function on Object only when clicking a button in Slate


I am using Slate, and running a Foundry Function on Object (FoO) based on input from users of the application. However, anytime a user changes one of the input, the function re-runs, which seems inefficient.

Is there a way to run the Function only when a user clicks a specific button? I have tried using the conditional triggers, but the function still runs anytime a text field changes.


Solution

  • Slate is pretty powerful, and we can leverage the event system to do this properly. As we noticed, the function runs any time a change happens to one of its input. So we have to control when those changes happen. The way to do is is to have the following logical sequence of events:

    This creates a sort of "gap" between the input fields and the function itself - the function will only run when the button is clicked.

    In practice, this looks like this -

    General setup of the application https://i.sstatic.net/41dAL.png

    Create an empty variable, and add an event computing the expected input of your function when clicking the button https://i.sstatic.net/41dAL.png

    Make sure that your function is using the variable as an input https://i.sstatic.net/41dAL.png