Skip to content

Commit f52636b

Browse files
Display_BR_script.js
1 parent dfa7bcf commit f52636b

File tree

1 file changed

+19
-0
lines changed
  • Server-Side Components/Business Rules/Use_case_Base64-Encode-Before-Save-And-Decode-on-Display

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Decode on Display Trigger: Before Display
2+
////Decodes fieldName from Base64. Shows decoded value on the form.
3+
4+
(function executeRule(current) {
5+
if (current.fieldName) { // field name can be anything
6+
try {
7+
var decoded = GlideStringUtil.base64Decode(current.fieldName);
8+
current.setDisplayValue('fieldName', decoded);
9+
} catch (ex) {
10+
current.setDisplayValue('fieldName', '[Invalid Base64]');
11+
}
12+
}
13+
})(current);
14+
15+
//If the field is new or updated, encodes its value to Base64. Saves the encoded string to the database.
16+
17+
// For Example User enters Hello World in fieldName.
18+
//Before saving : System encodes and stores SGVsbG8gV29ybGQ= in the database.
19+
//When the record is viewed : Display rule decodes it back to Hello World for the user.

0 commit comments

Comments
 (0)