• crop-1645
  • NEWBIE
  • 5 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Hi All,

How to know metadata information of duplicate rules like Record-Level Security,Action on create,Action on edit from APEX or API 

                     User-added image

I am having a problem accessing the content of an encrypted field from an Apex class. According to the Encrypted Field documentation -- "When an encrypted custom field is manipulated in Apex Code, the value is always unmasked,regardless of the permissions of the user. " However, in my Apex code the field value is always masked.

 

I confirmed this by parsing the actual field value character by character, since encrypted fields are always masked in system.debug() statements.

 

Participant__c partic = [SELECT ID, Social_Security_Number__c FROM Participant__c WHERE ID = :this.recordID LIMIT 1];
if (partic.Social_Security_Number__c != null) {
	string ssn = '';
	for (integer n = 0; n < partic.Social_Security_Number__c.length(); n++) {
		string x = partic.Social_Security_Number__c.subString(n,n+1);
                if (x == '*') x= 'x';
                ssn += x;
    	}
}

 In the above code I found that the characters in the encrypted field were actually an asterik (*). I confirmed this by checking for the "*" and replacing it with a "+".  (I could have done this with a Replace(), but I wanted to actually copmare each character one at a time to be sure).

 

Shouldn't I be able to retrieve the full umasked value of the encrypted field in my Apex code?

 

Best Regards,

 

Mike