- 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:11 PM
The line:
if (some condition) {
actually needs to have a condition. Your example was cut off so I substituted as a generic if else.
Also, the document.location should be somewhere in whatever client side javascript you want to execute. Based on what you have there it should go in the addMe function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2017 03:16 PM
My bad, i coped note pad code.
Here is the actual code. its not working. Any idea ?
<?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>
<g2:evaluate var="jvar_url" jelly="true">
var url = '';
if (current.short_description != "") {
url = "kb_find.do?sysparm_search=" + encodeURI(current.short_description) + "$[AMP]sysparm_operator=IR_OR_QUERY$[AMP]sysparm_order=relevancy$[AMP]sysparm_stack=no$[AMP]sysparm_query=sys_id!=" + current.sys_id;
} else {
url = '$knowledge.do#/search?query=' + encodeURI(current.short_description) + '$[AMP]order=default';
}
url;
</g2:evaluate>
<script>
addMe(reference)
{
document.location = "${jvar_url}";
}
</script>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2017 03:18 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2017 03:24 PM
i figured out that , my bad forgot to add "function".
but its now redirecting to the same page instead of knowledge list.
it should redirect to page with search knowledge articles.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2017 03:34 PM
Here is my complete use case.
1. User trying to create a new knowledge article
2. Enter the short description and click on the icon next to it to find duplicate knowledge articles
3. it will call the UI macro with below 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>
<g2:evaluate var="jvar_url" jelly="true">
var url = '';
url = "kb_find.do?sysparm_search=" + encodeURI(current.short_description) + "$[AMP]sysparm_operator=IR_OR_QUERY$[AMP]sysparm_order=relevancy;
url;
</g2:evaluate>
<script>
function addMe(reference)
{
document.location = "${jvar_url}";
}
</script>
</j:jelly>
4. As per the expected result. it should redirect to knowledge list page like show below.
5. current failure :
its redirecting to same page.