How to launch a dialog screen after logging in
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2024 12:01 AM
After I log in, I want to show the select box on the dialog screen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2024 12:13 AM
Hi @BoHyun Jung,
To launch a dialog screen with a select box immediately after a user logs in, you can utilize the User Preference records or a UI Page with a Client Script. The general approach involves checking for a specific condition or flag when the user logs in and, based on that, displaying the dialog screen. Below is a guide on how to set this up using a UI Page and Client Script.
Step 1: Create a UI Page
First, create a UI Page that will serve as the dialog screen you want to show after login.
1. Navigate to **System UI > UI Pages** in the application navigator.
2. Click **New** to create a new UI Page.
3. Give your UI Page a name and title.
4. In the HTML section, you can create your dialog box structure. For a select box, you would include something like this in your HTML:
```html
<select id="mySelectBox">
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<!-- Add more options as needed -->
</select>
```
5. You can also add client scripts at the bottom of the UI Page to manage actions based on the user's selection.
### Step 2: Create a UI Script
If you want to launch the dialog automatically after login, you might need a UI Script that checks for the user's login and then displays the dialog.
1. Navigate to **System UI > UI Scripts**.
2. Click **New** to create a UI Script.
3. Name your script and ensure it's set to be global if you want it to run for all users.
4. You can use a script similar to this:
addLoadEvent(function() {
// You can add conditions here if needed
var dialog = new GlideModal('your_ui_page_name');
dialog.setSize(400, 200); // Set the size as needed
dialog.render();
});
```
### Step 3: Load the UI Script on Login
To ensure this script runs when a user logs in, you can either embed it in a global UI Page that's loaded for all users or use a User Preference to trigger it for specific users.
### Using a User Preference (Recommended for targeting specific users or conditions):
1. Navigate to **System Settings > User Preferences**.
2. Create a new User Preference where the name is something like `login.dialog.shown` and set the value to `false` by default.
3. Modify the UI Script to check this preference and only show the dialog if the preference is `false`. After showing, update the preference to `true`.
This setup should help you achieve your goal of showing a select box in a dialog screen right after a user logs in to ServiceNow.
Please hit helpful and acccept this as a solution if it solved your problem.
Thank you !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2024 06:42 PM - edited ‎03-27-2024 12:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2024 08:58 PM
HI @BoHyun Jung ,
I trust you are doing great.
Follow the below step for the dialog box :
1. Create a UI Page:
<select id="mySelectBox">
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
</select>
2. Create a Client Script:
Set the "Applies to" field to the appropriate table (e.g., sys_user_session
if you want it to execute after logging in).
function onLoad() {
var dialog = new GlideModal('your_ui_page_name'); // Replace 'your_ui_page_name' with the name of your UI page
dialog.setTitle('Select Box Dialog');
dialog.render();
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2024 01:47 AM