- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2018 06:13 AM
I am using g_form.getDisplayBox('reference field').value in a UI action as below.
function searchCompany() {
var url = 'http://www.bing.com/search?q=';
var company = (g_form.getDisplayBox('reference_field').value);
window.open(url + company , '_blank');
}
For example, Reference field value = Apple & Pie, the URL searches just 'Apple'
However, it works fine for values with , and space. Just the '&'. Any thoughts?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2018 06:46 AM
Try this...
function searchCompany() {
var url = 'http://www.bing.com/search?q=';
var company = (g_form.getDisplayBox('u_group').value);
company = encodeURIComponent(company).toString();
window.open(url + company);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2018 03:39 PM
Hi Mark,
Is g_form.getDisplayBox() a deprecated method?
How come best practice says do not get reference values directly from the client script but rather make an ajax call to get to let the server return the values?
Thank you
Miguel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2018 01:44 AM
Hi Miguel,
It's not deprecated. The display value is actually stored in the client so you don't need to make a server side call just to get the display value of a reference field.
If you need to get any other details on the referenced record then best practice is to use Glide Ajax rather than getReference() or a client side glide record.
Cheers
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2018 06:22 AM
Hi Latha,
Can you explain your requirement here?
That could be because browser is unable to convert it into %26.
you can have once check
search for & character and replace it with %26 and it should work
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2018 06:25 AM
Oops, looks like you've spelled google wrong in your URL as well 😄
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2018 06:35 AM
Hi Latha,
Update your script as below and it should work fine.
function searchCompany() {
var url = 'http://www.bing.com/search?q=';
var company = (g_form.getDisplayBox('reference_field').value);
company = company.replace(/&/g, "%26");
window.open(url + company , '_blank');
}
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader