File tree Expand file tree Collapse file tree 3 files changed +67
-0
lines changed
Client-Side Components/UI Scripts/User acknowledgement Using UI script and user preferences Expand file tree Collapse file tree 3 files changed +67
-0
lines changed Original file line number Diff line number Diff line change 1+ < ?xml version = "1.0" encoding = "utf-8" ?>
2+ < j :jelly trim = "false" xmlns :j = "jelly:core" xmlns :g = "glide" xmlns :j2 = "null" xmlns :g2 = "null" >
3+ < g :ui_form >
4+ < div class = "modal-body" >
5+ < h1 class = "text-center" > Important Message</ h1 >
6+ < p > Please read and acknowledge this important message before proceeding.</ p >
7+ < p >
8+ Your access will be revoked if you don't log in for 30 days!
9+ </ p >
10+ < div class = "text-center" style = "margin-top: 20px;" >
11+ < button id = "acknowledge_btn" class = "btn btn-primary" onclick = "return closeDialog();" > Acknowledge</ button >
12+ </ div >
13+ </ div >
14+ </ g :ui_form >
15+ < script >
16+ (function() {
17+ function closeDialogAndRedirect ( ) {
18+ try {
19+ GlideDialogWindow . get ( ) . destroy ( ) ;
20+ } catch ( e ) { }
21+
22+ // Set user preference
23+ if ( typeof setPreference === 'function' ) {
24+ setPreference ( 'login.consent1' , 'true' ) ;
25+ }
26+ // Redirect to home.do
27+ window . top . location . href = 'home.do' ;
28+ }
29+ document . getElementById ( 'acknowledge_btn' ) . addEventListener ( 'click' , closeDialogAndRedirect ) ;
30+ } )();
31+ </ script >
32+
33+ </ j :jelly >
Original file line number Diff line number Diff line change 1+ addLoadEvent ( function ( ) {
2+ try {
3+ // Skip contexts where GlideDialogWindow isn't available (e.g., Service Portal)
4+ if ( typeof GlideDialogWindow === 'undefined' || ( window . NOW && NOW . sp ) )
5+ return ;
6+ var prefName = 'login.consent1' ;
7+ // Only show the dialog when the pref is explicitly 'false'
8+ var val = ( typeof getPreference === 'function' ) ? getPreference ( prefName ) : null ;
9+ var shouldShow = String ( val || '' ) . toLowerCase ( ) === 'false' ;
10+ //alert("val"+" "+val+" "+"shouldShow"+" "+shouldShow);
11+ if ( ! shouldShow )
12+ return ;
13+ var dialog = new GlideDialogWindow ( 'acknowledgement_dialog' ) ; // UI Page name
14+ dialog . setTitle ( 'Acknowledge Message' ) ;
15+ dialog . setSize ( 500 , 300 ) ;
16+ dialog . render ( ) ;
17+ } catch ( e ) {
18+ if ( console && console . warn ) console . warn ( 'ack loader error' , e ) ;
19+ }
20+ } ) ;
Original file line number Diff line number Diff line change 1+ ** Create a user preference as follows:**
2+ <img width =" 1675 " height =" 420 " alt =" image " src =" https://github.com/user-attachments/assets/efcd19dd-f1ad-440a-ae59-10cc63832cad " />
3+ ** Create a UI script:**
4+ <img width =" 1646 " height =" 808 " alt =" image " src =" https://github.com/user-attachments/assets/207f9dfa-4c6c-4686-84ac-3ff5294a0771 " />
5+ This script runs during login and checks the user preference.
6+ If the preference is set to false, it displays the acknowledgement popup by calling UI page
7+
8+ ** UI Page details:**
9+ <img width =" 1511 " height =" 897 " alt =" image " src =" https://github.com/user-attachments/assets/74d4be0f-9401-4733-81df-fca8f52b644e " />
10+ Set the user preference to true so that the popup will not appear for every login.
11+
12+ ** Output** :
13+ ** On user login:**
14+ <img width =" 1896 " height =" 748 " alt =" image " src =" https://github.com/user-attachments/assets/1af1b7ec-4647-4bb4-a786-8070817b21f8 " />
You can’t perform that action at this time.
0 commit comments