Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
Update a credential of type "API Key" via Flow designer scoped action - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • Update a credential of type "API Key" via Flow designer scoped action
KB0832166

Update a credential of type "API Key" via Flow designer scoped action


870 Views Last updated : Feb 26, 2024 public Copy Permalink
KB Summary by Now Assist

Issue

  • Cannot update the api_key record with the new api_key (string) since the only accepted type is "password2".
  • Tried to script and action like the next example:
var table = 'api_key_credentials'; //Table which contains the password 2 way field.
var record_sys_id = 'ab1dfb07db35d05086f0272913961953'; // sys_id of the record for which the password field needs to be Changed.
var password2WayField = 'api_key'; // Field name for the password field to be decrypted.

var encrypter = new GlideEncrypter();
var r = new GlideRecord(table);
r.addQuery('sys_id', record_sys_id);
r.query();
while(r.next()){
gs.print('Decrypted: ' + encrypter.decrypt(r.getValue(password2WayField) + '') + ' Encrypted: ' + r.getValue(password2WayField));
r.api_key=encrypter.encrypt("NewCredentials");
r.update();
gs.print('Decrypted: ' + encrypter.decrypt(r.getValue(password2WayField) + '') + ' Encrypted: ' + r.getValue(password2WayField));
}

 

  • Although it does not get any error, the code does not make any change.

Release

All

Cause

Base on documentation, GlideEncrypter is used on scripts running on Global scope

- Refer to the documentation page Glide Encrypter Api reference

2. As long as the action is not running on Global scope, it will finish with error, not always visible by user: "GlideEncrypter is not allowed in scoped applications"

Resolution

For GlideEncrypter consider to create a custom action under Global scope as it is the only way to make the script work.


The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.