File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Server-Side Components/Business Rules/Base64-Encode-Before-Save-And-Display Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ //This is Before Insert/Update Business Rule to automatically store sensitive data in Base64 form.
2+
3+ ( function executeRule ( current , previous ) {
4+ if ( current . u_field1 . changes ( ) ) {
5+ var plainText = current . u_field1 + '' ;
6+ current . u_field1 = GlideStringUtil . base64Encode ( plainText ) ;
7+ }
8+ } ) ( current , previous ) ;
9+
10+
11+
12+
13+
14+ //this is Display busiess rule to make sure users see the decoded text instead of Base64
15+
16+ ( function executeRule ( current ) {
17+ if ( current . u_field1 ) {
18+ try {
19+ var decoded = GlideStringUtil . base64Decode ( current . u_field1 ) ;
20+ current . setDisplayValue ( 'u_field1' , decoded ) ;
21+ } catch ( ex ) {
22+ current . setDisplayValue ( 'u_field1' , '[Invalid Base64]' ) ;
23+ }
24+ }
25+ } ) ( current ) ;
You can’t perform that action at this time.
0 commit comments