- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
We have an requirement to store the password in custom table field (A),
1.The password needs to be editable and viewable only to specific users.
2.Whenever the users try to view or edit the password field (A), the moment they click on the field or toggle the icon we have to make the reason field (B) visible and mandatory and this needs to be enabled for audit purpose, like who has viewed or modified the password and we have to get this details in the reporting as well.
If we have any OOB/custom solution to accomplish this requirement, kindly provide your thoughts here.
Thanks in Advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Natraj S
ok got your point, so please uncomment the line in client script that sends the Record ID (sys_id) to the server. Also , inside script include use that ID to find the record (gr), decrypt the password, and send it back in the JSON object.
UI Action scriptt:
function unlockField(reason) {
var ga = new GlideAjax('PasswordSecurityHelper');
ga.addParam('sysparm_name', 'logAccessAndUnlock');
ga.addParam('sysparm_reason', reason);
// IMPORTANT: This MUST be uncommented.
// The server needs to know WHICH record to look up.
ga.addParam('sysparm_record_id', g_form.getUniqueValue());
ga.getXMLAnswer(function(response) {
var result = JSON.parse(response);
if (result.success) {
// Unlock the field (Visual only)
g_form.setReadOnly('u_mfg_password', false);
g_form.flash('u_mfg_password', 'green', 0);
g_form.addInfoMessage('Access granted.');
// Display the password returned from the server
if(result.decrypted_password) {
// Use g_form.setValue if you want it to appear in the field
// g_form.setValue('u_mfg_password', result.decrypted_password);
// OR use alert to pop it up (Safer)
alert("The Password is: " + result.decrypted_password);
}
}
});
}
script icnlude:
logAccessAndUnlock: function() {
var reason = this.getParameter('sysparm_reason');
var docId = this.getParameter('sysparm_record_id'); // Get the ID sent from Client
// 1. Initialize the Return Object
var response = {};
response.success = false;
// 2. DEFINE 'gr' - Look up the record
// REPLACE 'your_custom_table_name' WITH YOUR ACTUAL TABLE NAME
var gr = new GlideRecord('your_custom_table_name');
if (gr.get(docId)) { // If we find the record matching the ID
// 3. Decrypt the password
// Note: Contextual Security (ACLs) might block this if not Admin/Authorized
var enc = new GlideEncrypter();
var decryptedValue = enc.decrypt(gr.u_mfg_password);
// 4. Build the response
response.success = true;
response.decrypted_password = decryptedValue; // Send the actual text back
}
return JSON.stringify(response);
},
Happy to help! If this resolved your issue, kindly mark it as the correct answer ✅ and Helpful and close the thread 🔒 so others can benefit too.
Warm Regards,
Deepak Sharma
Community Rising Star 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Natraj S
ok got your point, so please uncomment the line in client script that sends the Record ID (sys_id) to the server. Also , inside script include use that ID to find the record (gr), decrypt the password, and send it back in the JSON object.
UI Action scriptt:
function unlockField(reason) {
var ga = new GlideAjax('PasswordSecurityHelper');
ga.addParam('sysparm_name', 'logAccessAndUnlock');
ga.addParam('sysparm_reason', reason);
// IMPORTANT: This MUST be uncommented.
// The server needs to know WHICH record to look up.
ga.addParam('sysparm_record_id', g_form.getUniqueValue());
ga.getXMLAnswer(function(response) {
var result = JSON.parse(response);
if (result.success) {
// Unlock the field (Visual only)
g_form.setReadOnly('u_mfg_password', false);
g_form.flash('u_mfg_password', 'green', 0);
g_form.addInfoMessage('Access granted.');
// Display the password returned from the server
if(result.decrypted_password) {
// Use g_form.setValue if you want it to appear in the field
// g_form.setValue('u_mfg_password', result.decrypted_password);
// OR use alert to pop it up (Safer)
alert("The Password is: " + result.decrypted_password);
}
}
});
}
script icnlude:
logAccessAndUnlock: function() {
var reason = this.getParameter('sysparm_reason');
var docId = this.getParameter('sysparm_record_id'); // Get the ID sent from Client
// 1. Initialize the Return Object
var response = {};
response.success = false;
// 2. DEFINE 'gr' - Look up the record
// REPLACE 'your_custom_table_name' WITH YOUR ACTUAL TABLE NAME
var gr = new GlideRecord('your_custom_table_name');
if (gr.get(docId)) { // If we find the record matching the ID
// 3. Decrypt the password
// Note: Contextual Security (ACLs) might block this if not Admin/Authorized
var enc = new GlideEncrypter();
var decryptedValue = enc.decrypt(gr.u_mfg_password);
// 4. Build the response
response.success = true;
response.decrypted_password = decryptedValue; // Send the actual text back
}
return JSON.stringify(response);
},
Happy to help! If this resolved your issue, kindly mark it as the correct answer ✅ and Helpful and close the thread 🔒 so others can benefit too.
Warm Regards,
Deepak Sharma
Community Rising Star 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
@Natraj S
Happy to help 😊. Keep Growing together