You need to sign in to do that
Don't have an account?
uma52551.3972270309784705E12
Apex Trigger Help
Hi Friends,
Here is my issue. Please advise me or help me.
I am having a field called Id_Generator__c which is autonumber field under object named custom_account__c. Now I have to write a trigger that will take this autonumber field and encrypt that field and then it has to send that encrypted value to the document I am sending out for signature(esignature) and then after signature the trigger has to get the key and decrypt that and have to store that value. Please let me know if you guys have any idea.
Thanks,
Here is my issue. Please advise me or help me.
I am having a field called Id_Generator__c which is autonumber field under object named custom_account__c. Now I have to write a trigger that will take this autonumber field and encrypt that field and then it has to send that encrypted value to the document I am sending out for signature(esignature) and then after signature the trigger has to get the key and decrypt that and have to store that value. Please let me know if you guys have any idea.
Thanks,
try this link of encrypted fields . https://help.salesforce.com/apex/HTViewHelpDoc?id=fields_about_encrypted_fields.htm
You can use the Crypto class to encrypt or decript. please see the below links:
https://developer.salesforce.com/page/Apex_Crypto_Class
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_crypto.htm
Thanks,
Sivasankar
I am able to write a trigger and generate an encrypted key. Here is the code I used to generate the key. I also created a temporary varaible called Id_Generator_Key__c and store the encrypted value in that key.
rigger EncrypOfAgIdGeneratorTrigger on Custom_Account__c (before insert) {
for (Custom_Account__c ca : Trigger.new) {
DateTime now = System.now();
String formattednow = now.formatGmt('yyyy-MM-dd')+'T'+ now.formatGmt('HH:mm:ss')+'.'+now.formatGMT('SSS')+'Z';
String GeneralId = ca.Id_Generator__c + formattednow;
System.debug('GeneralId:'+GeneralId);
Blob bsig = Crypto.generateDigest('MD5', Blob.valueOf(GeneralId));
System.debug('Blob value:'+bsig);
ca.Id_Generator_Key__c = EncodingUtil.base64Encode(bsig);
}
}
And Now I am passing this key to the URL 'https://cs16.salesforce.com/apex/SignUp?Id=yFjMsJE1MifGnnT6oYKefQ=='
Now I want to write a separate class for decryption and have to call this class once the page loaded and then I have to use the id_Generator__c field for the rest of the code. Can any one help how to write decryption code in separate class and how to call that class after loading my above page. Thanks in advance!