- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2023 09:15 AM
Hi,
I've a field "PAN Card Number" in user table. Whenever the user fills this field, I want to mask the value like BCXXXXXX1D. How can I do this? And how can I retrieve its value when needed?
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2023 10:20 AM
Hello @Vasu ch
Write Before BR on the same table and use condition pannumber isnot empty
And use below script-
(function executeRule(current, previous /*, g*/) {
var panField = 'pan_number'; // Change this to match your field name
var visibleChars = 2; // Number of characters to leave visible (e.g., the first two and the last character)
var pan = current.panField;
if (pan && pan.length >= (visibleChars + 2)) {
// Create a masked PAN
var prefix = pan.substring(0, visibleChars); // First two characters
var maskedChars = 'X'.repeat(pan.length - (visibleChars + 2)); // Masked characters
var suffix = pan.slice(-1); // Last character
var maskedPAN = prefix + maskedChars + suffix;
current.panField = maskedPAN;
}
})(current, previous);
Please accept my solution and mark as helpful.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2023 10:20 AM
Hello @Vasu ch
Write Before BR on the same table and use condition pannumber isnot empty
And use below script-
(function executeRule(current, previous /*, g*/) {
var panField = 'pan_number'; // Change this to match your field name
var visibleChars = 2; // Number of characters to leave visible (e.g., the first two and the last character)
var pan = current.panField;
if (pan && pan.length >= (visibleChars + 2)) {
// Create a masked PAN
var prefix = pan.substring(0, visibleChars); // First two characters
var maskedChars = 'X'.repeat(pan.length - (visibleChars + 2)); // Masked characters
var suffix = pan.slice(-1); // Last character
var maskedPAN = prefix + maskedChars + suffix;
current.panField = maskedPAN;
}
})(current, previous);
Please accept my solution and mark as helpful.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2024 06:21 AM
But how can we fetch the actual PAN value when required?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2023 11:44 AM
Hi @Vasu ch ,
Try below script in before BR when pan not empty
(function executeRule(current, previous /*null when async*/) {
var panCard = current.u_pan_number;
if (panCard) {
var maskedPan = panCard.substring(0, 2) + "XXXXXX" + panCard.substring(8, 9);
current.u_pan_number = maskedPan;
}
})(current, previous);
Please mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand