- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2017 02:23 PM
Folks,
I am trying to generate a simple URL in UI macro and call. its failing sysparam needs a demiliter.
code:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j:set var="jvar_n" value="add_me_${ref}"/>
<span id="${jvar_n}" onclick="addMe('${ref}')" title="Add me" alt="Add me" tabindex="0" class="btn btn-default icon-default-knowledge-base">
<span class="sr-only">Add me</span>
</span>
<script>
function addMe() {
var url = "https://"+window.location.hostname.toString()+"/kb_knowledge.do?sys_id=-1&sysparam_query=short_descriptionLIKEMAJOR";
window.open(url, "_blank");
return false;
}
</script>
</j:jelly>
How to call a url with param value ?
Thank you,
Eashwar Elumalai
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2017 04:34 PM
Sorry the way I was doing it (i.e. based on the ui macro) required the form to be saved before it would work. LIkely what was the issue. This version does not:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j:set var="jvar_n" value="add_me_${ref}"/>
<span id="${jvar_n}" onclick="addMe('${ref}')" title="Add me" alt="Add me" tabindex="0" class="btn btn-default icon-default-knowledge-base">
<span class="sr-only">Add me</span>
</span>
<script>
function addMe(reference)
{
window.open('$knowledge.do#/search?query=' + encodeURI(g_form.getValue('short_description')) + '$[AMP]order=default');
}
</script>
</j:jelly>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2017 03:37 PM
Try this...I didn't notice the current references (it is not in scope in the ui macro, so I had to query the record). I also replaced document.location with window.open as I figured we didn't want to overwrite the page:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j:set var="jvar_n" value="add_me_${ref}"/>
<span id="${jvar_n}" onclick="addMe('${ref}')" title="Add me" alt="Add me" tabindex="0" class="btn btn-default icon-default-knowledge-base">
<span class="sr-only">Add me</span>
</span>
<g:evaluate var="jvar_url" jelly="true" object="true" >
var url = '';
var inc = new GlideRecord('incident');
if (inc.get(jelly.sys_id)) {
if (inc.short_description != "") {
url = gs.getProperty('glide.servlet.uri') + "kb_find.do?sysparm_search=" + encodeURI(inc.short_description) + "$[AMP]sysparm_operator=IR_OR_QUERY$[AMP]sysparm_order=relevancy$[AMP]sysparm_stack=no$[AMP]sysparm_query=sys_id!=" + inc.sys_id;
} else {
url = gs.getProperty('glide.servlet.uri') + '$knowledge.do#/search?query=' + encodeURI(inc.short_description) + '$[AMP]order=default';
}
}
url + '';
</g:evaluate>
<script>
function addMe(reference)
{
window.open("${jvar_url}");
}
</script>
</j:jelly>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2017 03:39 PM
BTW, my example was from the incident form...you probably want to replace GlideRecord('incident') with GlideRecord('kb_knowledge') for your purposes.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2017 03:40 PM
Or actually kb_submission based on your screenshot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2017 03:59 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2017 04:03 PM
Is there any reason you don't use the dictionary attribute knowledge_search=true? Give me a moment and I'll move my ui macro to the kb_submission table, but if you add that attribute to the short_description field, I think it provides much the same functionality.