- 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 07:29 AM
Whereas this solution may work for your specific use case of the problematic "&" character, you are better off encoding the company name as both Chuck and Mark suggested. This will work with any problem characters:
function searchCompany() {
var url = "http://www.bing.com/search?q=";
var company = encodeURIComponent((g_form.getDisplayBox("company").value));
window.open(url + company , "_blank");
}
You are better off using the encodeURIComponent function now instead of running into an issue with another character later on.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2018 07:43 AM
Thats what I did 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2018 11:47 AM
OK, that's good. Thanks for the update.