Populate the reference field value

Elvin_Salim
Tera Contributor

There is a reference field that displays a filtered record using Script include and Reference qual in the field. It displays the matching record and the user has to click on the record to select it in the field. How can I make the record auto populate in the field without the user having to click and select it?

5 REPLIES 5

Shashank_Jain
Kilo Sage

@Elvin_Salim , You’ll need client-side scripting to detect when there’s only one matching record and then set the value automatically.

 

When the form loads, the client script calls the Script Include.

 

  • If only one record matches, it returns the sys_id and display_value.

  • Client script then auto-fills the reference field for the user.

Hope it helps!

 

 

If this works, please mark it as helpful/accepted — it keeps me motivated and helps others find solutions.
Shashank Jain

Ankur Bawiskar
Tera Patron
Tera Patron

@Elvin_Salim 

there's no point in auto populating as there could be multiple records satisfying that filter.

which one you will auto-populate?

This is not a good user UI experience.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Elvin_Salim 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi @Ankur Bawiskar ,

 

Thanks for your time and the response. I solved it by moving the logic from script include to business rule.

 

BR,

Elvin