• Loureiro@UPF
  • 10 Points
  • Member since 2018

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 3
    Likes Given
  • 2
  • 3
Once created my APEX webservice, how can I know who is calling it?
I mean how can I get the URI of the caller?
When deploying bettwen sandboxes I have this (known) error
profiles/Admin.profile -- Error: You may not modify the permission Update Consent Preferences Using REST API while editing a Standard Profile

I can remove the conflicting permission but... which one?
where can i find the correspondence between Metadata strings and descriptions?
When deploying bettwen sandboxes I have this (known) error
profiles/Admin.profile -- Error: You may not modify the permission Update Consent Preferences Using REST API while editing a Standard Profile

I can remove the conflicting permission but... which one?
where can i find the correspondence between Metadata strings and descriptions?
I have tried below code for email validation:

String emailRegex = '^[a-zA-Z0-9_|\\\\#~`=?$^!{}+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z]{2,4}$';

valid email is like sanju.test@test.com should be accetable.
how to write code for below condition
1. Number of characters before @ should be equal or less than 64 characters
2. Below character should NOT be acceptable.
3. First and Last character should NOT be "."

Thank you in advance

I'm trying to make a call to a WebService that requires the Soap Security Header to be provided in the message. They also require Password Digest.

I am able to POST a message to the service, and getting the response I'm looking for, using a tool such as SOAP UI. In the log I see the Soap Header looks like this

<soapenv:Header><wsse:Security soapenv:mustUnderstand="1" 
<wsse:UsernameToken wsu:Id="UsernameToken-0A895E4ED2XY1B64BB142239383782811>
    <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">kxPMdaV96UNV1OXw0B83IpnwgNc=</wsse:Password>
    <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">LTYzMDgmJTU1MTE5ODgyMjQ2HOZ==</wsse:Nonce>

What I'm trying to do is to create this header in an Apex Class.
I highligheted in BOLD (above) the "variable" fields.

- For Password Digest, I'm generating the string using the process below

            Blob targetBlob = Blob.valueOf('mypass');
            Blob hash = Crypto.generateDigest('SHA1', targetBlob);
            String b64 = EncodingUtil.base64Encode(hash);  

- For Nonce, I'm generating the string using the process below

            Long randomLong = Crypto.getRandomLong();
            String Nounce = EncodingUtil.base64Encode(Blob.valueOf(String.valueOf(randomLong)));

- For Created, I'm generating the string using the process below

            String Create = Datetime.now().formatGmt('yyyy-MM-dd\'T\'hh:mm:ss\'Z\'');

I am not sure what goes in the wsu:Id="UsernameToken part of the header. How are tools such as SOAP UI generating a different and accepted Token in each call?

Any help or ideas on this would be highly appreciated

I've lost some time fighting with the package.xml in order to retrieve and deploy matching rules and duplicateRules.

So if this helps, here is an example of the package.xml :
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
As you can see there an 's' on the matching rules name but not on the duplicate rules name!
The same for unitary members:
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
 Im getting the following error and cannot figure out why: 

System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Email address is invalid: null: [toAddresses, null]

Class.email_class.send: line 48, column 1
Class.TestquoteEmailclass.sendEmailTestMethod: line 47, column 1

Below is my test class: 
public class TestquoteEmailclass {
    @isTest static void sendEmailTestMethod(){
        Product2 prod = new Product2(Name = 'SLA: Bronze', IsActive = true);
        insert prod;
        PricebookEntry pbe=new PricebookEntry(unitprice=0.01,Product2Id=prod.Id, Pricebook2Id=Test.getStandardPricebookId(), IsActive= true); 
        insert pbe; 
        Account acc = new Account (name='Acme');
        insert acc;
        Opportunity opp= new Opportunity (name='Testopp', Accountid=acc.id, CloseDate= date.today(), StageName='Closed Won', Pricebook2id=Test.getStandardPricebookId());
        insert opp; 
        OpportunityLineItem oppLine = new OpportunityLineItem( pricebookentryid=pbe.Id,TotalPrice=2000, Quantity = 2,Opportunityid = opp.Id);
        insert oppLine;       
        Quote q= new Quote (Name='Testq', Opportunityid=opp.id, QuotetoInvoice__c= True,  Pricebook2id=Test.getStandardPricebookId());
        insert q;
     Attachment objAtt = new Attachment();
     objAtt.Name = 'Test';
     objAtt.body = Blob.valueof('string');
     objAtt.ParentId = q.Id;
     insert objAtt;

         ApexPages.StandardController sc =new ApexPages.StandardController(q); 
        email_class ec=new email_class (sc);
        ec.emailCC= 'test3@gmail.com';
         Messaging.InboundEmail email = new Messaging.InboundEmail();  
         Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
        email.plainTextBody = 'This should become a note';
        email.fromAddress ='test@test.com';
        String contactEmail = 'jsmith@salesforce.com';
        email.ccAddresses = new String[] {'Jon Smith <' + contactEmail + '>'};
        email.subject = 'Dummy Account Name 123';



And my controller:
public class email_class{
    Public string ToAddresses {get;set;}
    Public string CCAddresses {get;set;}
    Public string quoteId {get;set;}
    Public string subject {get;set;}
    public string email_body {get;set;}
    public string emailTo {get;set;}
    public string emailCC {get;set;}
     public  string [] ccaddress;   
        public email_class(ApexPages.StandardController controller) {
                quoteId = ApexPages.currentPage().getParameters().get('id');
    Public PageReference send(){

                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); // set the to address
                mail.setToAddresses(new String[] {emailTo}); 
               // mail.setCCAddresses(new String[] {emailCC});   //set the cc address
        if(emailCC != null && emailCC.trim() != '')
        ccaddress = emailCC.split(',',0);

                List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();

                for (Attachment a : [select Name, Body, BodyLength from Attachment where ParentId = :quoteId]){  // Add to attachment file list  
                        Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();  
                mail.setFileAttachments(fileAttachments);// Send email
                Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
                return null;

Any help is appreciated !
  • January 26, 2017
  • Like
  • 1
Hello Community- seasoned Admin, but beginner developer here!

I'm building a Visualforce page that will serve as the default landing page for my Salesforce Community, and as a personal touch would like to display a nice welcome message and content that would render dynamically, based on who is logging in.  As far as merge fields go, I'm all set.

However where I'm getting stuck is to conditionally display a set of images stored in Documents, based on the Current User's value in the Company field({!$User.CompanyName}).

I've attempted to write logic using IF/ELSE IF/ELSE commands, however it's just not rendering correctly.  In short, here's what I'm trying to achieve:

If User's Company Name = 'Company 1', display Logo 1
If User's Company Name = 'Company 2', display Logo 2
..and so on..
...and so on...
....Else, display nothing

Thanks in advance for any suggestions you can provide!