There’s two types of password fields in ServiceNow — this goes both for creating a new field, and creating a new system property. Here’s the skinny on how they’re different and how to use them…
- Use this when you don’t need to use the password anywhere in your code. You never need to decrypt it.
- This is used primarily for the sys_user.password field. The system asks you for a password, encrypts it via the same method, and then checks if it matches.
- Use this when you DO need to use the password in your code.
- I’ve got a password “asdf” stored in a system “Password2” system property.
- In my code, I can now do the following to get the plain text password back:
var encryptedPass = gs.getProperty("config_pass"); var pass = new GlideEncrypter().decrypt(encryptedPass);