Skip to content

Commit 3fdfa00

Browse files
authored
Html input field in glide modal window (#2069)
* Created UI page * Created UI Action * Created README.md * Delete Core ServiceNow APIs/GlideModal/README.md * Created README.md file and placed it in the correct folder
1 parent fd0d926 commit 3fdfa00

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Add HTML Input Field in GlideModal Window - ServiceNow
2+
3+
## Use Case
4+
This snippet demonstrates how to include HTML input fields, including rich text editors, inside a GlideModal window in ServiceNow.
5+
6+
## Real-Life Example of Use
7+
In ServiceNow ITSM, support agents often need to add detailed notes or updates quickly without losing their workflow context. For instance, when investigating complex incidents, agents can click the "Add Details" button to open a modal with rich text input to document findings, attach formatted comments, or paste troubleshooting steps. This modal dialog prevents navigation away from the incident form, speeding up data entry and improving information capture quality.
8+
9+
## Why This Use Case is Unique and Valuable (Simple)
10+
- Lets users enter rich text and HTML inputs right inside a popup window (GlideModal) without leaving the current page.
11+
- Makes data entry faster and easier by avoiding navigation away from the form.
12+
- Supports complex inputs like formatted text using editors such as TinyMCE.
13+
- Helps improve quality and detail of notes and comments on records.
14+
- Can be reused for different input forms or workflows in ServiceNow.
15+
- Works smoothly within the ServiceNow platform UI for a consistent user experience.
16+
17+
## Steps to Implement
18+
1. Create a UI Page named `rich_text_modal` with appropriate input fields (string and rich text).
19+
2. Create a UI Action (e.g., "Add Details") on the Incident table that opens the `rich_text_modal` UI Page within a GlideModal.
20+
3. Open an incident record and click the "Add Details" button to see the modal with the HTML input fields.
21+
22+
## Compatibility
23+
This UI Page and UI Action is compatible with all standard ServiceNow instances without requiring ES2021 features.
24+
25+
## Files
26+
`UI Page` , `UI Action` - are the files implementing the logic.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function test()
2+
{
3+
var dialog = new GlideModal('rich_text_modal');
4+
dialog.setTitle('Rich Text Editor');
5+
dialog.setSize('500','500');
6+
dialog.render();
7+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
4+
<!-- Short Description (String) -->
5+
<label for="short_description">Short Description</label><br/>
6+
<input type="text" id="short_description" name="short_description" style="width: 100%;" maxlength="100" /><br/><br/>
7+
8+
<!-- Full Description (Rich Text/HTML) -->
9+
<label for="full_description">Full Description</label><br/>
10+
<script src="/scripts/tinymce4_4_3/tinymce.full.jsx"></script>
11+
12+
<script>
13+
tinymce.init({
14+
mode : "specific_textareas",
15+
editor_selector : "mce",
16+
width: '100%',
17+
height: '500px',
18+
menubar: "tools",
19+
toolbar: 'undo redo | bold italic | alignleft aligncenter alignright | bullist numlist',
20+
content_css : "* {font: 10px arial, sans-serif;} b {font-weight:bold;} th {font-weight:bold;} strong {font-weight:bold;}",
21+
});
22+
23+
</script>
24+
<textarea cols="80" rows="10" id="myArea" name="myArea" class="mce"></textarea>
25+
<br/>
26+
<br/>
27+
<div style="text-align: left;">
28+
<button type="button" id="submitBtn" onclick="submitForm()">Submit</button>
29+
</div>
30+
<script>
31+
// Example submit handler function:
32+
function submitForm() {
33+
alert("form submitted");
34+
}
35+
</script>
36+
</j:jelly>
37+

0 commit comments

Comments
 (0)