Skip to content

Commit 0c577ea

Browse files
authored
User acknowledgement using u iscript and userpreferences (#1785)
* Create script.js * Delete Background scripts directory * Create Convert comma separated values in string to columns * Delete Convert comma separated values in string to columns * Create MID Server availability inside MID cluster.js * Create reame.md * Update MID Server availability inside MID cluster.js * Delete Flow Actions/Check MID Servers status inside MID Server cluster directory * Create UIscript.js * Create UIpage.js * Create readme.md
1 parent da74be6 commit 0c577ea

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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" />

0 commit comments

Comments
 (0)