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-03-2023 08:20 PM
Hi @Amit Gujarathi , how do you apply the Client script since all of this are in ESC portal's widget?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2023 10:37 PM
Hello @Amit Gujarathi
Thanks for the reply but the thing I am looking for is on employee center.
The solution is similar to what @Community Alums has provided but additionally I want to show the alert while approving some specific catalog item only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2023 11:05 PM
Hi @mr18 ,
I have done it, it requires quite a lot of steps but will give you the details, I just want to re-test it first
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2023 11:09 PM
Thank you @Community Alums
Will wait for your update
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2023 12:43 AM
Hi @mr18 , please try below if it works your case, I tested it.
During implementation, you may need to switch between Employee Center and Employee Center Core applications.
Also you can name these cloned widgets of your choice, just make sure to reference it correctly in another widgets.
Application: Employee Center
- Clone "action-widget" widget (https://[instance-name].service-now.com/nav_to.do?uri=sp_widget.do?sys_id=38a3a159530201101865ddeeff...😞
- ID field is "action-widget-copy"
- -> Save
- Clone "task-configuration" widget (https://[instance-name].service-now.com/nav_to.do?uri=sp_widget.do?sys_id=b96b4449535301105a1eddeeff7b12b4):
- ID field is "task-configuration-copy"
- Server script: line 67 -> replace "action-widget" with "action-widget-copy"
- -> Save
- Inside "action-widget-copy" (cloned in Step 1):
- Client Controller:
line 18: recordNumber: $scope.data.actionButtons[0].clientParams.number.value
- line 20: c.executeClientScript(action, resp.data.actionOutput, resp.data.showAlert);
- Client Controller:
- line 45: c.executeClientScript = function(action, serverScriptOutput, showAlert) {
- line 47: if (showAlert == true) {alert('Confirmation box')}
- Server script:
- Line 34:
if (input && input.hasOwnProperty('recordNumber')) {
if (input.recordNumber.startsWith('RITM')) {
var grRITM = new GlideRecord('sc_req_item');
grRITM.addQuery('number', input.recordNumber);
grRITM.query();
if (grRITM.next()) {
if (grRITM.cat_item == '039c516237b1300054b6a3549dbe5dfc') {
data.showAlert = true;
}
}
}
}
Application: Employee Center Core
- Inside "HRM Todos Summary" widget (https://[instance-name].service-now.com/nav_to.do?uri=sp_widget.do?sys_id=bdc676957317130030f331d7ca...
- Client controller (line 98): replace "task-configuration" with "task-configuration-copy" (cloned from step 2)