- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 07:42 PM
HI,
I have created a UI Button , if user clicks on that UI button my script include should Execute... Please help me with the script to call script include from UI Action
Below is the script include :
AjaxClientHelperTest1.prototype = Object.extendsObject(AbstractAjaxProcessor, {
validateExcel: function() {
var ticketSysID = this.getParameter('sysparm_ticketSysID');
var v_aFinalArr = [];
.
;
Thanks,
M..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 07:52 PM
Hi,
There are two things here based on your requirement.
Script include can be called in UI Action using both Client and Server types.
1) If you want to call a Script Include in Server side of UI Action you can use below syntax:
new ScriptIncludeName().FuctionName(parameter if any);
2) Looking at your screenshot looks like you have created a Client callable Script Include so you need to sue below syntax:
var ga = new GlideAjax('asu_GetLocationData');
ga.addParam('sysparm_name', 'getCampus');
ga.addParam('sysparm_buildingid', g_form.getValue("u_building"));
ga.getXML(updateCampus);
}
function updateCampus(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
}
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 07:46 PM
Hi Manasa,
You can call the script include using GlideAjax in your UI action code.
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 07:52 PM
Hi,
There are two things here based on your requirement.
Script include can be called in UI Action using both Client and Server types.
1) If you want to call a Script Include in Server side of UI Action you can use below syntax:
new ScriptIncludeName().FuctionName(parameter if any);
2) Looking at your screenshot looks like you have created a Client callable Script Include so you need to sue below syntax:
var ga = new GlideAjax('asu_GetLocationData');
ga.addParam('sysparm_name', 'getCampus');
ga.addParam('sysparm_buildingid', g_form.getValue("u_building"));
ga.getXML(updateCampus);
}
function updateCampus(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
}
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 07:59 PM
Also to note one important thing in UI Action if you want to do a Client side behavior in your UI Action then you need to follow couple of important parameters here as shown below:
1) Make sure to define a Action Name and check the Client Check box
2) Define on On click function as shown below
3) Sample code shared below on how to call a Script Include in your UI Action in both Client and Server side section in the same UI Script:
There is a good article on this , please refer the same for more info:
https://servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2024 11:55 AM - edited 01-20-2024 11:58 AM
Hi @Manasa23
First things first, make sure you check the 'Client callable' box on the Script Include form, which will automatically format your code to be client callable (as shown below):
Once that's done, you can call the Script Include on the UI Action with the following code:
new ScriptIncludeName().FunctionName();
To see what that looks like in the actual UI Action Condition field, see the image below:
And that's it! If you are having trouble with the Script Include/GlideAjax portion, then Shawn Dowler's GlideAjax cheat sheet will help you out.
Please mark Correct or Helpful if my response helped you.
You can also find a full guide for how to call a script include from UI Action here.