How to Retrieve selected Dropdown value in UI Builder

vtred
Tera Contributor

Hi, I created a custom Dropdown component on UI Builder and the dropdown component has three value for user to choose.

 

Dropdown:

value 1

value 2

value 3

 

How do i retrieve the value selected by user?

Example: I used this command to retrieve the value entered in a text area: event.payload.fieldValue

3 REPLIES 3

Community Alums
Not applicable

Did you solve this one? I'm also looking for the same, Please let me know if you find the solution

Community Alums
Not applicable

Found the solution, You need to create a client state parameter. In the event handlers, Click on Add an event handler and select 'Update Client state parameter' in the options. Now select the client state parameter you added in the first field. In the second field, you need to get the value of the selected drop-down value: Type  "@payload.value " in the field and click on add. 

 

In order to pass this value to the system, You need to create a data source and call the data source in the client script

'selectedValue' is my client state parameter, I'm passing the selected dropdown value to the shortdescription

function handler({api, event, helpers, imports}) {
    const input = api.state.selectedValue[0]; 
    const user = api.context.session.user.sys_id;
    const fields = 'assigned_to='+user+'^short_description='+input;
    
    api.data.create_record_1.execute({
        "table":"incident",
        "templateFields": fields,
        "useSetDisplayValue":false,
    })
}

 

 

Hey Sai,

 

That was really helpful. I used " const input = api.state.selectedValue[0]; " to get the selected dropdown option value in client script. I used it to sort columns in table. However its working fine in Safari Browser, But in chrome its not working properly. Columns are not getting sorted out in ascending /descending order.

Is there any way we can use the method which will work in any browser to fetch the array data??