Skip to content

Commit 32e779c

Browse files
authored
Json formatter (#2217)
1 parent 84baa00 commit 32e779c

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
This solution provides a significant User Experience (UX) enhancement for fields that store complex data in JSON format (e.g., integration payloads, configuration properties, or setup data).
2+
3+
Instead of forcing users (developers, administrators) to read or edit raw, unformatted JSON in a plain text area, this macro adds a "JSON Viewer" button next to the field
4+
5+
Name json_formatter_macro
6+
Active true
7+
Type XML
8+
9+
Navigate to **System UI > UI** Macros and create a new record named json_formatter_macro , Use XML Attached File as Script
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="jelly:html" xmlns:g2="glide.ui">
3+
4+
<g:evaluate var="jvar_field_name" expression="RP.getWindowProperties().get('fieldName')" />
5+
6+
<button type="button"
7+
onclick="openJsonViewer('${jvar_field_name}');"
8+
title="View and Format JSON"
9+
class="btn btn-default btn-sm">
10+
<span class="icon-code"></span> JSON Viewer
11+
</button>
12+
13+
<script>
14+
function openJsonViewer(fieldName) {
15+
var jsonValue = g_form.getValue(fieldName);
16+
var gm = new GlideModal('json_viewer_ui_page', false); // Replace 'json_viewer_ui_page' with your actual UI Page or Widget ID
17+
gm.setTitle('JSON Data Viewer & Formatter for Field: ' + fieldName);
18+
gm.setPreference('json_data', jsonValue);
19+
gm.setSize(900);
20+
gm.render();
21+
}
22+
</script>
23+
</j:jelly>

0 commit comments

Comments
 (0)