Calling a function in UI Action from Script Inlcude without making the SI client callable

charutha
Tera Contributor

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!!

2 ACCEPTED SOLUTIONS

@charutha 

 

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.

View solution in original post

@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

View solution in original post

7 REPLIES 7

@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

Voona Rohila
Mega Patron
Mega Patron

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

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 !!