diff --git a/Server-Side Components/Background Scripts/inserting a new record into the sys_user table/README.md b/Server-Side Components/Background Scripts/inserting a new record into the sys_user table/README.md index 2d91314167..74cffc2b70 100644 --- a/Server-Side Components/Background Scripts/inserting a new record into the sys_user table/README.md +++ b/Server-Side Components/Background Scripts/inserting a new record into the sys_user table/README.md @@ -1,3 +1,3 @@ -# inserting a new record into the sys_user table. -With this code, we are creating a new GlideRecord object for the 'sys_user' table, initializing it, setting the values for the 'user_name,' 'first_name,' 'last_name,' and 'email' fields, and then inserting a new record into the 'sys_user' table with the specified values. -In sys_user table a new rcord will be created +# Create User in ServiceNow (sys_user Table) +This script is used to create a new record in the sys_user table in ServiceNow. +It initializes a GlideRecord object, sets the required user details (username, first name, last name, and email), and inserts the record in sys_user table. diff --git a/Server-Side Components/Background Scripts/inserting a new record into the sys_user table/script.js b/Server-Side Components/Background Scripts/inserting a new record into the sys_user table/script.js deleted file mode 100644 index 1d6d720d99..0000000000 --- a/Server-Side Components/Background Scripts/inserting a new record into the sys_user table/script.js +++ /dev/null @@ -1,7 +0,0 @@ -var gr=new GlideRecord('sys_user'); -gr.initialize(); -gr.user_name='test.user'; -gr.first_name='test'; -gr.last_name='user'; -gr.email='test.user@servicenow'; -gr.insert(); diff --git a/Server-Side Components/Business Rules/Base64-Encode-Before-Save-And-Display/README.md b/Server-Side Components/Business Rules/Base64-Encode-Before-Save-And-Display/README.md new file mode 100644 index 0000000000..6985a0a18e --- /dev/null +++ b/Server-Side Components/Business Rules/Base64-Encode-Before-Save-And-Display/README.md @@ -0,0 +1,11 @@ +Base64 Encode Before Save / Decode on Display + +Explanation: + +Goal: Store sensitive or formatted data (like text) in an encoded format in the database while still allowing users to see and interact with the readable version. + +Before Insert/Update → Encode (secure storage). + +Before Display → Decode (user-friendly display). + +It’s a example of data transformation for secure storage and transparent display. diff --git a/Server-Side Components/Business Rules/Base64-Encode-Before-Save-And-Display/Script.js b/Server-Side Components/Business Rules/Base64-Encode-Before-Save-And-Display/Script.js new file mode 100644 index 0000000000..6d4b445913 --- /dev/null +++ b/Server-Side Components/Business Rules/Base64-Encode-Before-Save-And-Display/Script.js @@ -0,0 +1,25 @@ +//This is Before Insert/Update Business Rule to automatically store sensitive data in Base64 form. + +(function executeRule(current, previous) { + if (current.variblename.changes()) { + var plainText = current.variblename + ''; + current.variblename = GlideStringUtil.base64Encode(plainText); + } +})(current, previous); + + + + + +//this is Display busiess rule to make sure users see the decoded text instead of Base64 + +(function executeRule(current) { + if (current.variblename) { + try { + var decoded = GlideStringUtil.base64Decode(current.variblename); + current.setDisplayValue('variblename', decoded); + } catch (ex) { + current.setDisplayValue('variblename', '[Invalid Base64]'); + } + } +})(current);