- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2023 09:06 PM
Hi ,
How can i call a function in UI Action defined on Script include without making the script include client callable?
I have a script Include which defines one function . And I need to call this function in UI Action.But the requirment is
the Script Incude should not be Client callble and the UI action 'Client' field should be false.
From Screen Shot: I need to call 'checkTaskCompletion' function in my UI Action.
Also I am aware of the fact that we can use Glide Ajax method to call the function in UI Action, if the Script Include is client callable!
Any help is much appreciated !!Thank you!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2023 09:56 PM - edited 01-18-2023 09:57 PM
Just store the answer in a variable
var response = new demoscriptinclude().checkTaskCompletion() ;
gs.info(response); // check system logs what is the output coming in the variable
Use "response" variable as per your requirement.
Please mark my answer helpful, if it resolved your query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2023 12:25 AM
@charutha
As you are using Server side UI action:
var response = new demoscriptinclude().checkTaskCompletion();
gs.info(response);
if (response != '') {
gs.addErrorMessage(response);
}
else {
gs.addErrorMessage('No task are opened');
}
Please use "gs" library, use gs.addErrorMessage OR gs.addInfoMessage
Please mark my answer helpful, if it works for you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2023 12:25 AM
@charutha
As you are using Server side UI action:
var response = new demoscriptinclude().checkTaskCompletion();
gs.info(response);
if (response != '') {
gs.addErrorMessage(response);
}
else {
gs.addErrorMessage('No task are opened');
}
Please use "gs" library, use gs.addErrorMessage OR gs.addInfoMessage
Please mark my answer helpful, if it works for you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2023 09:49 PM - edited 01-18-2023 09:50 PM
Hi @charutha
You can call the script include from UI Action like below
var gr = new Scriptincludename().functionname();
As per your code
var gr = new demoscriptinclude().checkTaskCompletion();
gr will store the returned value from the checkTaskCompletion function
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2023 10:04 PM
Thank you for your response!!
But it is not working .
var a = new demoscriptinclude().checkTaskCompletion();
if (a != '') {
g_form.addErrorMessage(a);
}
else {
alert('No tasks are opened');
}
Instaed of dispaying the error message , it is navigating back to the UI Action page.
Could you please help me !!