- 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
‎08-23-2018 06:20 AM
The underlying problem is that & is special to URLs. What you are actually telling is another parameter called Pie. You need to encode that query so & is turned in to %26. On the server side, you can do this with gs.urlEncode(). I recommend using this as a server side UI action. I don't see a big need for doing this client side.
var url = "http://yoursite.com/?search=";
var urlArg = gs.urlEncode(current.reference_field.getDisplayValue());
action.setRedirectURL(url + urlArg);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2018 06:21 AM
You need to encode the value you're getting. Try this...
function searchCompany() {
var url = 'http://www.bing.com/search?q=';
var company = (g_form.getDisplayBox('reference_field').value);
company = company.encodeURIComponent(company);
window.open(url + company , '_blank');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2018 06:27 AM
Mark, this does not work!

- 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);
}