• gbarger4581
  • NEWBIE
  • 0 Points
  • Member since 2009

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

I wrote a schedulable class that my company wants in order to send notifications about records that were submitted for approval more than 30 days ago, but still are not approved. My class works fine, but I cannot figure out how to write a test class for this. I need to be able to set the CreatedDate for these records because I want the test class CreatedDate to be more than 30 days old. Below is the query I use to build my list, but I can't create a test class where I insert and submit records for approval more than 30 days ago.

 

        ProcessInstanceWorkItem[] KYC = [Select processinstance.targetobjectid,actor.email
        from ProcessInstanceWorkItem where CreatedDate != LAST_N_DAYS:30 order by actor.email];

Hi, 

I have implemented a class which received an email with similar to:

 

Subject: RE:APPL001

Approved

The second Line

 

As you can see the body has two lines: 

1st Line : Approved

2nd Line: The second Line

 

My class is as follows: 

 

 

global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope env)
    {
        // Indicates if the message processes successfully, permits an error response to be send back to the user 
        Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
        try
        {

 

global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope env)    {        

Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();        
try        {
	System.debug('plainTextBody: ' + email.plainTextBody);
	String[] emailBodyArray = email.plainTextBody.split('\n', 0);
	System.debug('emailBodyArray[0]: ' + emailBodyArray[0]);
	if(emailBodyArray[1]!=null && emailBodyArray[1]!=''){
				comment = emailBodyArray[1];
				System.debug('ApprovalInb comment : ' + comment);
	}
catch (Exception e)
        {
            // Return an email message to the user
            result.success = false;
	}
}

 

 

}

 

When I send the above email, the logs show me: 

15:10:12.670|USER_DEBUG|[20,13]|DEBUG|plainTextBody: ApprovedThe second Line

 

As you can see above, the value of email.plainTextBody hasn't respected the return character between the two lines and has added both lines into one line only, therefore I am not able to process the body into an array with two items. 

Any one know why? 

 

  • June 02, 2010
  • Like
  • 0