Skip to main content
16-Pearl
March 28, 2025
Solved

Best Practice for Handling Either Dropdown or TextField Input (Exclusive Selection)

  • March 28, 2025
  • 1 reply
  • 544 views

Hello ThingWorx Community,

I'm currently working on a use case where a customer can either select a value from a dropdown or manually type a custom value into a text field. The idea is to give users flexibility in providing input.

Here’s the intended logic:

  • If the user selects a value from the dropdown and leaves the text field empty β†’ the selected value is passed to a service.

  • If the user enters a value in the text field and leaves the dropdown empty β†’ the typed value is passed to the same service.

  • If both fields are filled, the service should not execute. Instead, a status message should inform the user to only fill one field.

  • If neither field is filled, the service also should not execute and prompt the user.

I'm currently thinking to use an expression function to validate the input combination and trigger a service on button click accordingly.

 

Before I finalize this logic, I’d love to hear your thoughts:

  • Would there be a more elegant way to handle this validation and control flow (perhaps with validators or service parameter bindings)?

Appreciate any suggestions or shared experiences!

Thanks in advance,

Best answer by MA8731174

I have used validator and expression and it worked well and as expected. 

1 reply

MA873117416-PearlAuthorAnswer
16-Pearl
April 4, 2025

I have used validator and expression and it worked well and as expected.