Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

UI Page Button tag

Malathi Vinoth
Tera Contributor

Team,

 

I am in need for UI Page development for button tag.

I had requirement for UI Page display where need buttons to execute the Script include.

It would be very helpful how to call script include by passing parameters in button tag

1 REPLY 1

Prince Arora
Tera Sage

@Malathi Vinoth ,

 

Please use the below mentioned code
UI page:  <button onclick="myFunc('Test')">Test</button>

PRINCE_ARORA_0-1676275686528.png

Client Script: 
function myFunc(parm1){
var ga = new GlideAjax('sampleScriptInclude'); // name of the script include...
ga.addParam('sysparm_name','sample'); // name of the function
ga.addParam('sysparm_id',parm1); // if you want to pass some parameter in the backend
ga.getXML(responseFunc);
function responseFunc(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
}}

Script include:

PRINCE_ARORA_1-1676275785232.png

code:
sample: function() {
return "here is my code";
},

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact!