Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Querying encrypted field

samadam
Kilo Sage

Is there a way to query encrypted field through glide record? I am trying to query using gliderecord with a value but doesn't work. Is there any way to do this?

4 REPLIES 4

Aoife
Tera Guru

Did you try to encrypt the data to use in the query first:

var gc = global.GlideCryptoModule.getModule('global.acme_mod');
var value = 'test';
var encrypted = gc.encryptData(value);
gs.info('value: ' + value);
gs.info('Encrypted: ' + encrypted);
var decrypted = gc.decryptData(encrypted);
gs.info('Decrypted: ' + decrypted);
gs.info(decrypted == value);

Aoife

I tried it but no luck, don't see anything in the logs printed..This is a scoped application so wondering if it doesnt worked for scoped apps

I would think it would have to work in a scoped application, not sure why it wouldn't.  Need encryption in scoped apps too.  There might be a scoped version of it, would have to search the API docs.

 

Here's another encryption API that works in scoped apps:

var e = new global.Encrypter("abcdefghijklmnopqrstuvwx");
var secret = e.encrypt("test");
gs.info(secret); // => Zjem9344FZk=
gs.info(e.decrypt(secret)); // => test

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @samadam ,

Please refer below support article :-

Unable to see encrypted field information even though user has encrypted context 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy