Action with custom placeholder text in input fields

Is there a way to set custom placeholder text in the input fields for an Action? The user should see text that gives an example of how the input should be formatted (e.g. “xxx-xxx-xxxx” for a phone number input field) and that automatically clears itself out when the field is focused.

I can’t use default values for this primarily because I don’t want the example text to be used as an actual input value if the user fails to change it.

From the documentation for Forms, it appears that such is possible there, but I haven’t been able to find an equivalent for Actions.

Question originally asked by LuminosityXVII on Stack Overflow: palantir foundry - Action with custom placeholder text in input fields - Stack Overflow

Not today. If it’s a Function-backed Action, then you could create logic in the Function to handle the default value being submitted, but that is obviously far from ideal. If you need to validate phone number input patterns or other user inputs, you could use submission criteria and if users input something invalid they will see a red exclamation mark in the lower-left of the form with a tooltip that explains what’s wrong.

Thank you, that’s helpful. Follow-up question: is it possible to set submission criteria in the backing function? I’d like to do some transformation of the user input before checking against a regex. I’m currently doing that validation by throwing a UserFacingError when said regex check fails, but my understanding is that that doesn’t trigger until after the user submits the Action (and due to our current permissions setup, I have limited ability to test it).

LuminosityXVII

Sep 13, 2023 at 10:28

  • 1

I assume you’re referring to an Edit Function. If you throw a UserFacingError, the edits are not going to be applied. Submission Criteria can’t be linked to Functions – when it comes to validating user input they act like front-end validation helpers you might use in some Javascript library.

Ontologize

Sep 13, 2023 at 14:10

  • It’s a Create Function, I should have specified. I understand that it won’t create the object if it throws a UserFacingError, so the most critical part of the intended functionality is thankfully there at least. Unfortunate that I can’t have the Function prevent submission in the first place, though. I guess I’ll just need to use a more complicated regex in the Submission Criteria. Thank you!

LuminosityXVII

Sep 13, 2023 at 20:21

  • 1

If it’s really complicated you could forego the Action form entirely and let users input text into text fields, store those values in variables and do some validation on them, either with a variable transformation or a Function, and then use a button widget to let users submit the values to an Action. Just don’t display the Action form; use the variables you created as its default values instead.

Answer originally provided by Ontologize on Stack Overflow: palantir foundry - Action with custom placeholder text in input fields - Stack Overflow