Show alert on click of "approve" action in employee center approvals
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-01-2023 09:42 PM
How can I show alert on click of "approve" action in employee center approvals under My task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2023 10:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2023 09:23 PM
Thank you @Community Alums for the reply.
I want to show the alert only if the approval is coming from specific catalog item.
So is there any possibility where I can check the condition something like source_table is sc_req_item and cat_item is xyz.
Really appreciate for your help
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2023 09:08 PM
@mr18 , I just successfully implemented this but will involves with interacting with multiple Employee Center widgets including cloning and modifying both Client and Server scripts.
Let's see if we have any other alternative methods from anyone else
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2023 07:30 AM
HI @mr18 ,
I trust you are doing great.
You can add the confirmation box
Client script :
function confirmApproval() {
var currentRecord = g_form.getUniqueValue(); // Gets the unique ID of the current record
// AJAX to get details from the server
var ga = new GlideAjax('CustomApprovalCheck'); // 'CustomApprovalCheck' is the Script Include you'll create
ga.addParam('sysparm_name', 'checkApprovalSource');
ga.addParam('sysparm_record_id', currentRecord);
ga.getXML(checkResponse);
function checkResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer === 'true') {
var conf = confirm("Are you sure you want to approve this task?");
return conf; // Proceed with or cancel the action based on user choice
} else {
return true; // Proceeds normally if the condition is not met
}
}
}
Script include :
var CustomApprovalCheck = Class.create();
CustomApprovalCheck.prototype = {
initialize: function() {
},
checkApprovalSource: function(recordId) {
var gr = new GlideRecord('approval'); // Assuming 'approval' is the table
gr.get(recordId);
if (gr.source_table == 'sc_req_item' && gr.cat_item == 'xyz') { // Replace 'xyz' with the sys_id of the specific catalog item
return 'true';
}
return 'false';
},
type: 'CustomApprovalCheck'
};
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi