• Keira Arnot
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 5
    Replies
Write a validation rule for Phone Number is equal to 10 digits and 13 digits(if the user gives 11 and 12 digits also the error should throw) only then only the record should create,otherwise the error should throw.
Hi All

We have requirement to add digial signature authrozied by CA in PDF to ensure the security of the document send in email. 

I have created Apex class and Apex page to implement this functionality. I am not sure how to attach the signature created by Crypto.sign method in pdf document. Can anyone help me to attach certificate to PDF document?

Apex class:
public class CryptoSign {
    public static void generateCryptoSign(){
        PageReference pageRef = Page.ApexCryptoTest;
        Blob pdfDoc = pageRef.getContentAsPDF();
        
        String algorithmName = 'RSA-SHA1';
        String key = 'PKCS12 Key';
        Blob privateKey = EncodingUtil.base64Decode(key);
        
        // Using Crypto.sign PDF document generated from Apex page is digital signing
        Blob pdfDocSigned = Crypto.sign(algorithmName, pdfDoc, privateKey);
       
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setSubject('Email Subject');
        mail.setHtmlBody('Email with Signed PDF attachment');
        List<String> toAddr = new List<String>();
        toAddr.add('test@test.com');
        mail.setToAddresses(toAddr);
        
        List<Messaging.Emailfileattachment> attachments = new List<Messaging.Emailfileattachment>();
                
        Messaging.Emailfileattachment attach = new Messaging.Emailfileattachment();
        attach = new Messaging.Emailfileattachment();
        attach.setFileName('SignedPDF.pdf');
        attach.setBody(pdfDocSigned);
        attachments.add(attach);
        mail.setFileAttachments(attachments);
        
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }
}

Apex Page:
<apex:page >
    Test Apex page
</apex:page>
I want to format the standard phone number field values. Example value should be 123-456-9876 when we enter as 1234569876 in the phone field? Is it possible?
Hey,

I would like to display the telephone number of the primary contact in the opportunity. I tried to apply a custom field in SF. That did not work.

Now, I would like to define a field wich show me the telephone number. How can I define a field with apex or a visualeforce page?

The SOQL code is:
SELECT Contact.HomePhone FROM OpportunityContactRole WHERE IsPrimary = true

thanks for your answer.

Hi,

 

I am trying to write a validation formula that will allow two format types for UK phone numbers, these are;

01234 567890 and 0123 456 7890.

 

Whilst I can write a validation rule for one format type; 

 

NOT(REGEX(Phone, "\\d{4}( \\d{3})( \\d{4})")).

 

I cannot seem to write a rule that will allow for two. I had tried;

 

OR(NOT(REGEX(Phone, "\\d{4}( \\d{3})( \\d{4})")), NOT(REGEX(Phone, "\\d{5}( \\d{6})")))

 

But this does not work. Any advice to what I am hoping is a simple answer would be grateful.