• Scott Hirsch 7
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 5
    Replies
Hello,

I'm attempting to deploy some new code and our test class is failing due to the following error:

System.NullPointerException: Attempt to de-reference a null object
Stack Trace: Class.slackv2.invokePostMessage.makePostMessageRequest: line 30, column 1

We have the Salesforce for Slack (https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3A00000FnD9mUAF) app installed in our Org. According to the setup instructions, we have a Process Builder created to send a notification to Slack when a new Opportunity is created. If I disable this Process Builder, I am able to deploy the code. However, I don't want to have to disable this Process Builder every time I deploy in the future. The code in managed packages is not visible so I cannot determine exactly what I need to do 

Does anyone have a suggestion on how I can determine what the managed package class needs?

Here's the test class and the class itself:
@isTest
private class testCreateOpp {
    static testMethod void validateOpp() {
    
        // Create a new email and envelope object
        Messaging.InboundEmail email = new Messaging.InboundEmail() ;
        Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
        
        // Populate email
        email.plainTextBody = 'Body text';
        email.subject = 'Subject Line of Email';
       
        // Execute method
        createOpp createOppObj = new createOpp();
        createOppObj.handleInboundEmail(email, env);
    }
}

global class createOpp implements Messaging.InboundEmailHandler {
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope env){
    
        // Create an InboundEmailResult object for returning the result of the Apex Email Service 
        Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
        String myPlainText= email.plainTextBody;
        String OppAccountId = '0014600000A0aaaAAA';
   
        // New Opportunity to be created
        Opportunity newOpp = new Opportunity(Name = email.subject, 
            AccountId = OppAccountId, 
            CloseDate = system.today() + 15,
            Description = myPlainText, // Email Body
            StageName = 'Identified',
            Amount = 5000);
    
        // Insert new Opportunity
        insert newOpp;    
        
        // Set the result to true. No need to send an email back to the user with an error message   
        result.success = true;
    
        // Return the result for the Apex Email Service 
        return result;
    }
}
Hello,

I'm attempting to deploy some new code and our test class is failing due to the following error:

System.NullPointerException: Attempt to de-reference a null object
Stack Trace: Class.slackv2.invokePostMessage.makePostMessageRequest: line 30, column 1

We have the Salesforce for Slack (https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3A00000FnD9mUAF) app installed in our Org. According to the setup instructions, we have a Process Builder created to send a notification to Slack when a new Opportunity is created. If I disable this Process Builder, I am able to deploy the code. However, I don't want to have to disable this Process Builder every time I deploy in the future. The code in managed packages is not visible so I cannot determine exactly what I need to do 

Does anyone have a suggestion on how I can determine what the managed package class needs?

Here's the test class and the class itself:
@isTest
private class testCreateOpp {
    static testMethod void validateOpp() {
    
        // Create a new email and envelope object
        Messaging.InboundEmail email = new Messaging.InboundEmail() ;
        Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
        
        // Populate email
        email.plainTextBody = 'Body text';
        email.subject = 'Subject Line of Email';
       
        // Execute method
        createOpp createOppObj = new createOpp();
        createOppObj.handleInboundEmail(email, env);
    }
}

global class createOpp implements Messaging.InboundEmailHandler {
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope env){
    
        // Create an InboundEmailResult object for returning the result of the Apex Email Service 
        Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
        String myPlainText= email.plainTextBody;
        String OppAccountId = '0014600000A0aaaAAA';
   
        // New Opportunity to be created
        Opportunity newOpp = new Opportunity(Name = email.subject, 
            AccountId = OppAccountId, 
            CloseDate = system.today() + 15,
            Description = myPlainText, // Email Body
            StageName = 'Identified',
            Amount = 5000);
    
        // Insert new Opportunity
        insert newOpp;    
        
        // Set the result to true. No need to send an email back to the user with an error message   
        result.success = true;
    
        // Return the result for the Apex Email Service 
        return result;
    }
}