Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GlideEncrypter is not allowed in scoped applications

prasad48
Mega Guru

GlideEncrypter is not allowed in scoped applications.How can i access the function in scoped application?

7 REPLIES 7

The SN Nerd
Mega Sage
Mega Sage

Short answer: You can't.



Why are you developing in an application scope?


If you don't intend to put your app on the store or deploy it at your customers, you might want to reconsider your design choice.



Otherwise, you need to find an alternative API call.



Check out https://developer.servicenow.com/app.do#!/api_doc?v=helsinki&type=server&scoped=true



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

Inactive_Use408
Kilo Expert

It's ridiculous that you can't encrypt or decrypt anything in scoped app scripts.

You can use it in scoped apps like below

 

gr.password.getDecryptedValue() can be used in scope apps for scoped decrypt

 

gr.password.setDisplayValue('un-encrypted string goes here'); can be used for scoped encrypt

 

var encrypter = new GlideEncrypter();
var encrypted = encrypter.encrypt('Super Secret Phrase');
gs.info('encrypted: ' + encrypted);
var decrypted = encrypter.decrypt(encrypted);
gs.info('decrypted: ' + decrypted);

gr.password.getDecryptedValue();

gr.password.setDisplayValue('un-encrypted string goes here');

David266
Tera Contributor

The code in the previous reply did not work for me, however, there is a ScopedEncrypter class available for scoped apps (it's a Script Include!).

In my app, I used the code below:

var encryptedSecret = "<your encrypted secret goes here>";
var decryptedSecret = new global.ScopedEncrypter().decrypt(encryptedSecret);
 
 Edit: It looks like this script include is part of a plugin named "IHUB Spoke Util Pack [com.snc.ihub_spoke_util_pack]"