File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Client-Side Components/UI Actions/Close Related HR cases & HR tasks Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ // Demo- OnClick function to execute
2+ function demo ( ) {
3+ var ga = new GlideAjax ( 'sn_hr_core.close_items' ) ;
4+ ga . addParam ( 'sysparm_name' , 'getRelatedItems' ) ;
5+ ga . addParam ( 'sysparm_case_id' , g_form . getUniqueValue ( ) ) ;
6+ ga . getXMLAnswer ( function ( response ) {
7+ // If there exist related items
8+ var items = JSON . parse ( response ) ;
9+ if ( items . length > 0 ) {
10+ var msg = "This case has related items:\n" ;
11+ items . forEach ( function ( item ) {
12+ msg += "- " + item . type + ": " + item . number + "\n" ;
13+ } ) ;
14+ msg += "\nDo you want to close them as well?" ;
15+ if ( confirm ( msg ) ) {
16+ // close current HR case
17+ g_form . setValue ( 'state' , '3' ) ;
18+ g_form . save ( ) ;
19+ }
20+ } else {
21+ // If no related item is associated
22+ if ( confirm ( "No related items found. Close this case?" ) ) {
23+ g_form . setValue ( 'state' , '3' ) ;
24+ g_form . save ( ) ;
25+ }
26+ }
27+ } ) ;
28+ }
You can’t perform that action at this time.
0 commit comments