How to create UI page with two buttons yes or no when click Approve
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 12:13 AM
Hi Everyone,
I have a requirement when approver click Approve need to display dialog box with two buttons Yes and No
with display the content
"Have all tickets transferred appropriate group"
If click on Yes request should approve
If click on No state should not change
I create UI page with below code for create two buttons
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<div>
<h2>have all active tickets, tasks, and application approvers and support team been transferred to the appropriate group?</h2>
<button id="yes_button" class="btn btn-danger" onclick="yes_button();">Yes</button>
<button id="no_button" class="btn btn-secondary" onclick="no_button();">No</button>
</div>
</j:jelly>
Please help on create client script
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @Brahmi Pandla ,
Your HTML script is correct, now after that add script in that which will act as event listener on that event :
<script>
function yes_button() {
var ga = new GlideAjax(<ScriptInclude Name>);
ga.addParam('sysparm_name', 'createApproval');
ga.addParam('sysparm_sys_id', g_form.getUniqueValue());
ga.getXMLAnswer(function(response) {
if (response == 'success') {
alert("Approval record created successfully!");
location.reload();
} else {
alert("Failed to create approval: " + response);
}
});
}
function no_button() {
alert("No approval created. State remains unchanged.");
}
</script>
Then In script Include write this :
createApproval: function() {
var sysId = this.getParameter('sysparm_sys_id');
var appr = new GlideRecord('sysapproval_approver');
if(appr.sysId ){
appr.state = 'approved';
appr.approver = gs.getUserID();
appr.update();
return "success";
}
}
If my response helped mark as helpful and accept the solution.

