Notifications

20 views

Description

  • 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 = 'cd4cfb07db35d05086f0272913961953'; // 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 or Environment

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.

Article Information

Last Updated:2020-07-16 07:21:10
Published:2020-07-16