How to get values selected in Form Component in UI Builder?

Vivek Joshi
ServiceNow Employee
ServiceNow Employee

I am using a Form component in UI Builder to get data from the user. The data that the user is looking up is referencing 2 different tables.

find_real_file.png

Now before saving the form I want to run some backend logic to check whether this combination should be allowed to create the record or not.

I figured out there are 2 ways of doing that-

1- Using a Business rule on the backend to do the validation before saving the record, but by going through this approach I don't think I will be able to update the user about the record, whether it was created or if failed, why it failed.

2- Using an API call to create the record and get the response back and display it on the UI.

So for 2nd action I will need to get the values of these 2 fields and on click of Submit button instead of save(gForm) I will try to make a backend API call.

I am not able to find a way to get the values that are selected in the form.

And also after submitting how can we reset these fields to initial state where no values were selected.

1 REPLY 1

Brad Tilton
ServiceNow Employee
ServiceNow Employee

If you've created a page using the record page template you should have access to run both client scripts and business rules and show messages on your workspace record page. However, if you've created your page directly by adding the form fields component to the page I'm not sure those things are going to work.

I think your best bet is to use a business rule to handle the validation on the server side and then just display an error message.