How to write and use a JS function that accepts input parameters?

Use a Javascript function like explained here:

https://docs.retool.com/docs/custom-js-code#application-specific-preloaded-javascript

This is what it would like like for your example, notice the syntax change from function feetToInches(feet) to window.feetToInches = function(feet)

Then you just call the feetToInches() function normally any place in Retool that can do Javascipt, like here where I am using a function as a column value:

If you want to use the same function in your entire organization, you can put it in the your orgs' Settings/Advanced/Preloaded Javascript section.

1 Like