UI Builder Input field

Gabriella Alves
Tera Expert

Hello,

 

Someone knows how to get a text inserted in an input field and pass this value to a function in Client Script? 
I'm trying to learn UI Builder but nothing works.

 

Please, help me

3 REPLIES 3

Jerick I
Kilo Sage
Kilo Sage

@Gabriella AlvesCreate a state, use it as the default value, or use client script to set the value.

Gabriella Alves
Tera Expert

Could you give me an exemple?
I have this modal with input 

GabriellaAlves_0-1669471594691.png


I must take the input inserted by user, and once user click on Import, call a Script Include passing the value.

Casper6060
Mega Sage

To anyone else coming looking for a way to take the data of an input field this is how it is done.

 

First you create a client script give it the proper name and so on. Then you bind the client script to the event that needs to call it, so if you want a button to be the trigger, you bind that button to your client script.

 

Now inside your client script you get the value from the input field by writing event.payload.fieldValue.

The payload contains a JSON object that looks like this: payload:{"name":null,"data":"4","fieldValue":"1234"}

 

I'm not certain what name is, but data is the value entered that triggered the event, so if the text field already contains the text 123 and you press 4, like in my example above the data will contain 4 and fieldValue will contain all the text in the input.

If you then want to call a script include then you need to handle the script include calling from a "sys_ux_data_broker_transform" record and send the information to that. You can do that by creating another event and then calling that and passing the required parameters. Inside your "sys_ux_data_broker_transform" you can call your script include by calling the class directly since sys_ux_data_broker_transform is a server call that does not support GlideAjax.