Bite #17: Password vs Password2

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…

Password

  • 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.

Password2

  • Use this when you DO need to use the password in your code.
  • Example:
    • 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);