Masking field value

darshan-pra
Tera Expert

on form where active field set to true then firstname and lastname need to be get masked how to do the same ... which should be work in workspace as well as in native UI 

12 REPLIES 12

Matthew_13
Mega Sage

Hi Buddy,

If you need this to work in both Native UI and Workspace, the safest way is to do the masking server-side, not just with a UI Policy.

What I’d do:

  1. Create a Display Business Rule on that table.

    • Condition: active = true

    • In the script, replace what’s shown on the form with masked values (this only affects display, it doesn’t update the DB).

    Example:

    if (current.active) {
      current.first_name = "****";
      current.last_name  = "****";
    }
  2. If you also want to stop edits when Active = true, add a UI Policy to make First Name / Last Name read-only.

One thing i noticed to note: Only for visual masking. If this is for real data protection, you should also add ACLs so users can’t see the real values through lists, reports, or API.

This all will behave consistently in workspace and the classic UI; hope this helps my friend šŸ™‚

 

@darshan-pra - Please mark Solution Accepted and Thumbs Up if you found Helpful!

MJG

In the Workspace the same not working ... but working in native UI 

@darshan-pra 

I will recommend to use field level READ ACLs for this

Display BR or onLoad client script will run on form

But user can still see fields from List

Note: I still think this isn't a valid business requirement

šŸ’” If my response helped, please mark it as correct āœ… and close the thread šŸ”’ā€” this helps future readers find the solution faster! šŸ™

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Indeed; If it’s working in the native UI but not in Workspace, it usually means the solution is relying on something that only the classic UI supports (UI Policies, client scripts, field styles, decorators.

To make this work consistently in both Workspace and native UI, you have two realistic options:

  • Use field-level ACLs on First Name and Last Name and control read access when Active = true. This is the only approach that works everywhere and also properly secures the data.

  • If you specifically need to show **** instead of hiding the value, then you’ll need a separate masked/display field for Workspace and show that when Active = true. Classic UI masking tricks won’t be reliable in Workspace.

Basically, the issue aint with your logic — it’s the UI difference. Workspace won’t honor classic UI masking methods, and ACLs optionally combined with a masked display field are the recommended way forward.

 

@darshan-pra - Please mark Solution Accepted and Thumbs Up if you found Helpful!

MJG