AutoComplete with String field

Aishwarya37
Tera Contributor

We have an existing custom table with a set of values. When the user enters data in the field, it needs to check against the value in the existing table and existing column (same like reference field) and if value is not present, it has to save the new value (same like text field)

6 REPLIES 6

Vengadesh
Tera Guru

Can you elaborate on your question or issue?

 

So consider we have custom table "File Details". We have field as "File Name" where user can select from existing "File Name" (which need to define as self referencing field) and if required file name is not existing, then he can type new name in the same field. Something like self building fields.

 

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

there are 2 ways i can think of.

1) You can add this logic in a before insert/update Business Rule. In that BR check if the current data entered is already present or not, and if it is not then you allow it to be inserted.

EG

 

var rec= new GlideRecord("<table name>");
rec.addQuery("<field name>", current.<field name>);
rec.query();
if (grsim.next()) {
gs.info('<Add Error Message>')
  current.setAbortAction(true);
}

 

2) The field that you are running this logic against, Navigate to the dictionary and make it unique. This way the DB itself will only allow new/unique entries in this field for new rows and will not allow duplicates

EG

 

AnuragTripathi_1-1715608536762.png

 

PS, if this field is not on the form you may have to bring it by changing the form layout of the dictionary 

 

-Anurag

Hi Anurag, 
We want to allow user to type new value before inserting record in custom table. Same like select box, if user is selecting Other, then new text box will appear to enter new value.
But we need to achieve by using reference field

Consider we have custom table "File Details". We have field as "File Name" where user can select from existing "File Name" (which need to define as self referencing field) and if required file name is not existing, then he can type new name in the same field. Something like self building fields.