onClick function in UI page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2016 01:03 PM
I have a UI page, I have a button, which upon click call the client script and pass the context sysapproval record to client scrim. How can I do that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2016 01:06 PM
I have this for example:
In the ui page XML:
"Button"->
<g:dialog_button onclick="toKnowledge()" type="button" class="diabutt">More information</g:dialog_button>
"Hidden field with a variable"->
<input type="hidden" id="kb_article" name="kb_article" value="${article.number}"/>
Client Script:
function toKnowledge() {
var article= gel("kb_article").value;
var url = 'kb_view.do?sysparm_article='+article;
GlideDialogWindow.get().destroy();
window.location = url;
}
In this example the client script get the variable and paste it into the url and then redirect the user to that page instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2016 01:09 PM
YOu mean I can pass sysparm_id as well by setting the value in a hidden variable on the UI page and get it in the client script ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2016 01:15 PM
Yea, that should be any problem.
if I look back at my example I have a ui action that does this
UI Action;
var featwin = new GlideDialogWindow('newfeature');
featwin.setTitle('New release information');
featwin.setSize(700,600);
//remove the X in the upper right corner
featwin.removeCloseDecoration();
//Send with the number of the article
featwin.setPreference('number', g_form.getValue('number'));
featwin.render();
Then in the UI Page I have this. And it a extra check since I have another place calling the UI Page with the setPreference.
<g:evaluate>
//Check if its a KB article UI action or the UI Script rendering the window
//If there is a preference from the script it from the UI Action otherwise get the system property
if (RP.getWindowProperties().get('number')) {
var artnum = RP.getWindowProperties().get('number');
}
else {
var artnum = gs.getProperty('custom.newfeature.kbdocument');
}
var article = new GlideRecord('kb_knowledge');
article.get('number', artnum);
</g:evaluate>
So what ever you can throw in and get to a variable, you can put it in a hidden input and the catch it in the client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2016 01:19 PM
Actually I am trying to get the current context in client script section of UI page, like ${sysparm_id} and query the user table based on the this value