How to query records using encrypted text
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 02:46 AM - edited 10-31-2023 02:46 AM
I have created a string field "Product ID" of length 210 characters on catalog item table and then populated it with 200 long characters encryted text, but I am not able to query it, not even using GlideRecord, how can I solve this issue?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 02:54 AM
you can decrypt the string from this code
var encryptString = new GlideEncrypter();
var clearString = 'abcxyz';
var encrString = encryptString.encrypt(clearString);
var decrString = encryptString.decrypt(encrString);
gs.print("Decrypted string = " + decrString);
You can either use this in the "Calculated Value" field of your table field OR you can create a new field and populate the decrypted value in the new field.
Let me know if this helps you and mark it as helpful or Correct based on impact

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 02:55 AM
Hi,
Using an encrypted field suggests that you have some sensitive data in this field.
If so, why would you want to query this data?
Consider this scenario;
You query users with a certain password phrase, that gives results. This would mean you have gained access to that sensitive/protected field. You would know which user has which password.
That would be a severe security risk!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 03:06 AM
Basically it is a string in the encryted format, coming from the api response, I just saved it to the string field I customly created, but when I am using GlideRecord to query the records it just don't get the record.