- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2019 05:33 PM
Hello,
I am using a set of credentials in one of my script so that I can retreive some data.
Is there any place in ServiceNow where I can store these credentials so I can just call them in scripts ?
Best would be if they were a Password 2 field type so I can decrypt them in the script only or a password that I can encode.
I am interested if there is any standard place for storing this sort of intro, I would like to not add any fields or make modifications to other tables.
Any ideas ?
Thank you !
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2019 07:38 PM
Use system properties to store the password.
You can create a system property record of type password/password2.
for more details check the below link:
https://docs.servicenow.com/bundle/london-platform-administration/page/administer/reference-pages/task/t_AddAPropertyUsingSysPropsList.html
-satheesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2021 07:55 PM
See the Credentials module under Connections and Credentials. You could store your credentials as a Basic Auth type of credential for example if none of the other credential types is an exact match. The password is stored securely in a password2 type field. Then you can use a regular query on the [discovery_credentials] table, searching for your credentials by the name you stored them under to get the sysid of the credential record. Then use the following code to get the userid and password. For example, I created a set of credentials with the name "Test credentials":
var credentialRecord = new GlideRecord('discovery_credentials');
credentialRecord.addQuery('name', 'Test credentials');
credentialRecord.query();
if (credentialRecord.next()) {
var credentialSysID = credentialRecord.sys_id;
var provider = new sn_cc.StandardCredentialsProvider();
var credentials = provider.getCredentialByID(credentialSysID);
gs.info("User name: " + credentials.getAttribute("user_name"));
gs.info("Password: " + credentials.getAttribute("password"));
}