How to set field value in Form component - UI Builder

Bartek0301
Tera Contributor

Hello,

 

I'm trying to do simple thing in UI Builder but I cannot find a solution that will work correctly.

 

On my form I have two fields: select box and text field. Based on the selection in select box I want to automatically  populate a text field with some value and later save it with custom button by triggering Save action from the form data resource. 

 

Is there any way I can achieve above?

5 REPLIES 5

Muralidharan BS
Mega Sage

HI @Bartek0301 

 

That should be straightforward, there are a few ways, one easy way is

 

1. create a client state like below

MuralidharanBS_0-1718893308748.png

 

2. the component emits a payload, for example, I use a search box, and it emits searchTerm. Map this searchTerm to the client state created in step 1. 

MuralidharanBS_1-1718893402623.png

 

3. Now, the target component is mapped to display the client state.

MuralidharanBS_2-1718893487946.png

 

so if you now type anything in the search component, it will reflect in the bottom text component.

 

result

MuralidharanBS_3-1718893579264.png

 

 

 

 

 

Hello @Muralidharan BS 

Thank you for the reply. 

Your example is related to the custom inputs. In that case I am able to configure this behavior.

 

But I'm trying to achieve the same directly in the form component, for example I want to use Form component to show incident form and when I select one of the category I want to set some description and later save the form using custom button.

 

I tried to use client script and set the value by referencing to the field from form data resource and indeed I was able to set the value, but when I tried to save it, the value reverted back to the previous one.

 

Interesting is that when I did the same, but before saving I've just clicked on the updated field, everything work...

It seems like a bug but I can't rely on users will click on the field before saving. So I'm looking for some other options.

Hi @Bartek0301 ,

 

did your custom save button perform actual update on the backend? Is it the problem that save button is working on Form but it's not displaying updated value after successful save?

Nadeem Khoury
Tera Contributor

Hey @Bartek0301 

 

Were you able to find a solution, I'm facing same issue ? 

 

How you were able to resolve it ?