- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2024 06:57 AM - edited 07-01-2024 06:58 AM
Hi everyone,
I’ve created a UI action popup window with Yes and No buttons. The intended behavior is that when a user clicks the UI action button, a confirmation window should appear. If the user clicks ‘Yes,’ the task current task and the task related to the parent table should be canceled. However, currently, the popup window appears but doesn’t perform any action. Below, I’m sharing the script I’ve used. Can you please assist?
UI action :
HTML code:
Client side:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2024 12:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 12:50 AM
Hi @shaik23
you have used GlideRecord in client script it does not work so try below code
Please made the changes in your UI page script it will work fine.
in HTML of UI page make these changes
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j:set var="jvar_sys_id" value="${RP.getWindowProperties().get('sys_id')}"/>
<input id="record_sys_id" type="hidden" value="${jvar_sys_id}" />
<div>
<h2>Are you sure you want to cancel this UAR?</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>
in Client Script
function no_button() {
GlideDialogWindow.get().destroy(); // Destroy dialog window on 'no' button click
}
function yes_button() {
var sys_id = $j('#record_sys_id').val();
var grajax = new GlideAjax('UARMUpdates');
grajax.addParam('sysparm_name', 'UARUpdate');
grajax.addParam('sysparm_Id', sys_id);
grajax.getXMLAnswer(fetchvalue);
function fetchvalue(response) {
if (response) {
alert("cancelled all the UAR and its task");
}
}
}
Create client callable script include and and try these code
UARUpdate: function() {
var sysId=this.getParameter('sysparm_Id');
var gr = new GlideRecord('u_user_access_review');
if (gr.get(sysId)) {
gr.setValue('state', '8'); // Make sure 'closed_skipped' matches your state value
gr.update();
var taskGR = new GlideRecord('u_uar_task');
taskGR.addQuery('parent', sysId);
taskGR.addQuery('active', true);
taskGR.query();
while (taskGR.next()) {
taskGR.setValue('state', '4'); // Update task state to 'Cancelled'
taskGR.update();
}
return true; // Success
} else {
return false; // Error
}
},
Please mark my answer correct if it helps you
Thanks
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2024 12:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2024 01:01 AM - edited 07-03-2024 01:07 AM