- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2017 07:34 AM
Hi ServiceNow Community,
I would call a Script Include by pressing a button. For exemple:
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<button type="button">Script Include Execution</button>
</j:jelly>
Best Regards,
Davide.
Solved! Go to Solution.
- Labels:
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2017 09:01 AM
I've resolved in this way:
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<button type="button" onclick="runCode()">Execution</button>
<script>
function runCode()
{
var ga = new GlideAjax('NewIncludeClient');
ga.addParam('sysparm_name','function1');
ga.getXMLWait();
var result=ga.getAnswer();
alert(result);
}
</script>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2017 07:39 AM
Hi Davide,
This is how i do it:
<g:evaluate>
//CALL SCRIPT INCLUDE HERE AND FROM SERVER TAKE THE RETURN VALUE
var temp= new SCRIPTINCLUDE().FUCNTION();
</g:evaluate>
<button type="button">$[temp]</button>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2017 07:53 AM
thanks Anurag Tripathi , I've try your code,
but in this way Script Include running always, even if I not press on button.
I would only execute the script when I pressing on Button
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_gr" object="true">
var temp= new NewInclude().myFunction();
</g:evaluate>
<button type="button">execution $[temp]</button>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2017 08:14 AM
Hi Davide,
You can have your button like below and use a onClick function. This onClick function will be available in the client script part where you can use GlideAJAX to execute your script include.
<input id="buttonID" title="Button" class="button"
type="button" onclick="functionName();"
value="btn" />
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2017 08:15 AM
I think the button press is always going to end up running client side, so you would need to execute a client side function that uses glideajax to call the script include.
