Map encrypted field value from Record producer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2025 11:52 PM
Guys - We have a encrypted field on case table and we need to map that field with Record producer variable.
After mapping end user is getting error "ErrorInvalid attempt. Encrypted data could not be saved".
Please help
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 12:46 AM
if the end user is not having the role for that encryption context then that error will come.
how are you mapping the field ? via map to field or using script?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 06:04 AM
Steps to Resolve the Issue
1. Ensure the Record Producer Variable is Mapped Correctly
Verify that the Record Producer variable is mapped to the encrypted field on the Case table.
Go to the Record Producer configuration and check the Variable Mapping section to ensure the mapping is correct.
2. Check the Encryption Configuration
Navigate to System Definition > Tables and open the Case table.
Locate the encrypted field and check its Encryption Type:
If it uses Field Level Encryption, ensure the field is configured correctly.
If it uses Client-Side Encryption, ensure the Record Producer is configured to handle client-side encryption.
3. Validate the Data Format
Encrypted fields often require data in a specific format (e.g., Base64 encoded).
Ensure the data being passed from the Record Producer to the encrypted field is in the correct format.
If the field requires Base64 encoding, you may need to encode the data before saving it.
4. Use a Script to Handle Encryption
If the Record Producer cannot directly handle the encrypted field, you can use a Script to handle the encryption and mapping.
Option 1: Script in the Record Producer's "Script" Field
Open the Record Producer and go to the Script field.
Add the following script to handle the encryption and mapping:
javascriptCopy(function executeProducer(producer, variables) { // Get the value from the Record Producer variable var encryptedValue = variables.encrypted_field_variable; // Create a new Case record var caseGR = new GlideRecord('case'); caseGR.initialize(); // Set the encrypted field value caseGR.setEncryptedValue('encrypted_field', encryptedValue); // Set other fields as needed caseGR.short_description = variables.short_description; caseGR.description = variables.description; // Insert the Case record caseGR.insert(); })(producer, variables);