• Kimberly V. Miles
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
I have an apex data table to list cases related to a contract. However, I want to only display specific record types on the list. My current solution works fine, unless the most recent case (or first result of the list) is a different record type than specified. Then I get the above error. 
 
It also works fine as a standard visualforce page, but rendered as a PDF, it fails.
 
Any ideas on what I am doing wrong?

Is there any workarounds?
 
<apex:page renderAs="pdf" showHeader="false" sidebar="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false" standardController="Contract"> <apex:dataTable value="{!Contract.Claims__r}" var="claim" id="claimTableInfo" width="100%" rowClasses="odd,even" styleClass="claimRecordsTable" border="solid" cellpadding="5px"> <apex:column rendered="{!if(claim.recordTypeID == '012b0000000Kr2VAAS','true','false')}" styleClass="claimRecordsTable" width="170px"> <apex:outputText value="{!claim.CaseNumber}"/> </apex:column> <apex:column rendered="{!if(claim.recordTypeID == '012b0000000Kr2VAAS','true','false')}" styleClass="claimRecordsTable" width="170px"> <apex:outputText value="{0,Date,dd/MM/yy}"><apex:param value="{!claim.Claim_Form_Recevied_Date__c}" /></apex:outputText> </apex:column> </apex:dataTable> </apex:page>

Hello,

 

I require to create a private aes128 key, store the key in my org and use this key for encrypting and decrypting values. I've run into the following challenges though and have been a bit stumped by them.

 

- If I create a secret key using 

 

Blob cryptoKey = Crypto.generateAesKey(128);

 

If I use the following to get the key I get an "BLOB is not a valid UTF-8 string"  error.

 

String cryptoString = cryptoKey.toString();
System.debug('cryptoString= ' + cryptoString);

 

If I instead convert my created key to a hex value and use it in a encryptWithManagedIV( function I get the following error

 

"Invalid private key. Must be 16 bytes."

 

String hexRep = EncodingUtil.convertToHex(cryptoKey);
System.debug('hexRep=' + hexRep);
Crypto.encryptWithManagedIV('AES128', Blob.valueOf(hexRep), Blob.valueOf('just4testing'));

 

However using the generated crypto key directly in encryptwithManagedIV works fine

 

Blob encryptedData = Crypto.encryptWithManagedIV('AES128', Crypto.generateAesKey(128), Blob.valueOf('just4testing'));

 

 

As I wish to store my secret key generated by Crypto.generateAesKey(128) , as the hex represenation of it won';t work I guess I would need to store the BLOB in a field in my org.  This seems a bit unusual to me however can it even be done?

Can a BLOB be stored in a custom field?  If not does anyone know why I get an error with my HEX represenation of the secretkey above?

 

Thanks in advance for any help on this.