• Jonathan Osgood
  • NEWBIE
  • 20 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 4
    Replies
Hi Everyone,

Implementing a basic email handler to email an attachement and have it save as an account attachment (in the notes and attachment related list). I am able to create a new account, but not match and update an existing and most importantly, the email attachment does not land on the account reocrd. I beleive my email services setting are OK (set to accept All attachements). Here is my class:
 
global class EmailToSalesForce implements Messaging.InboundEmailHandler {
  global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, 
                                                         Messaging.Inboundenvelope envelope) {
  
Account account;
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();

try {



// Look for account whose name is the subject and create it if necessary
if ([select count() from Account where Name =:email.subject] == 0) {
  account = new Account();
  account.Name = email.subject;
  insert account;
} else {
  account = [select Id from Account where Name =:email.subject];
}



// Save attachments, if any
for (Messaging.Inboundemail.TextAttachment tAttachment : email.textAttachments) {
  Attachment attachment = new Attachment();
 
  attachment.Name = tAttachment.fileName;
  attachment.Body = Blob.valueOf(tAttachment.body);
  attachment.ParentId = account.Id;
  insert attachment;
}
for (Messaging.Inboundemail.BinaryAttachment bAttachment : email.binaryAttachments) {
  Attachment attachment = new Attachment();
 
  attachment.Name = bAttachment.fileName;
  attachment.Body = bAttachment.body;
  attachment.ParentId = account.Id;
  insert attachment;
}
      
      result.success = true;
      result.message = (email.subject + ' matched');
    } catch (Exception e) {
      result.success = false;
      result.message = 'Oops, I failed.';
    }
   
    return result;
  }
}

 
I know this has been convered, but I am still unable to properly display a lookup in my VF page. InputField references an actual lookup to Account. I've tried adding !Form.AccountID with no luck...

Here is the code:
 
<apex:page standardController="Form__c" showHeader="false" sidebar="false" standardStylesheets="false">

   <apex:form >

    <label>
      Which high school do you attend?<br/>
    </label>

    <div>
        <apex:inputField value="{!Form__c.High_School_Attended__c}" />
    </div>  

   </apex:form>

</apex:page>

Here is the field. 

User-added image
Hi All,

I am migrating an old prodcution org to a new one using eclipse. Getting failures due to lookup dependencies and wondering what the best practie/appraoch is here. Is this really just a tedious order of operations problem (deploy Object A first, then Deploy Object B)? Or is there another way to make this more efficient? Please see screenshot for example. 

Any advice greatly appreciated!

Jonathan
User-added image
Hi Everyone,

I have a requirement to capture images in the field, in an offline environment, then attach them to an account. 
Ideally, I could also create an account on mobile, then attach the image to the newly created account. 
The only app on the app exchange that came close was Timba lens, but that only allows you to attach to existing accounts. 

Any other ideas before going down the custom dev path?

Thanks! 
Hi All,

Configuring Communties self registration. After submitting new user login info, I  am redirected to an "Internal server error..." message (screenshot attached).  I have properly (I hope) updated the SelfRegController --adding a profile, role and account ID. Deployed to production with 85% Coverage and no problems. Also, the new user is correctly added to salesforce. 

Is this a navigation issue, perhaps?

Thank you!
Hi Everyone,

Implementing a basic email handler to email an attachement and have it save as an account attachment (in the notes and attachment related list). I am able to create a new account, but not match and update an existing and most importantly, the email attachment does not land on the account reocrd. I beleive my email services setting are OK (set to accept All attachements). Here is my class:
 
global class EmailToSalesForce implements Messaging.InboundEmailHandler {
  global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, 
                                                         Messaging.Inboundenvelope envelope) {
  
Account account;
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();

try {



// Look for account whose name is the subject and create it if necessary
if ([select count() from Account where Name =:email.subject] == 0) {
  account = new Account();
  account.Name = email.subject;
  insert account;
} else {
  account = [select Id from Account where Name =:email.subject];
}



// Save attachments, if any
for (Messaging.Inboundemail.TextAttachment tAttachment : email.textAttachments) {
  Attachment attachment = new Attachment();
 
  attachment.Name = tAttachment.fileName;
  attachment.Body = Blob.valueOf(tAttachment.body);
  attachment.ParentId = account.Id;
  insert attachment;
}
for (Messaging.Inboundemail.BinaryAttachment bAttachment : email.binaryAttachments) {
  Attachment attachment = new Attachment();
 
  attachment.Name = bAttachment.fileName;
  attachment.Body = bAttachment.body;
  attachment.ParentId = account.Id;
  insert attachment;
}
      
      result.success = true;
      result.message = (email.subject + ' matched');
    } catch (Exception e) {
      result.success = false;
      result.message = 'Oops, I failed.';
    }
   
    return result;
  }
}

 
I know this has been convered, but I am still unable to properly display a lookup in my VF page. InputField references an actual lookup to Account. I've tried adding !Form.AccountID with no luck...

Here is the code:
 
<apex:page standardController="Form__c" showHeader="false" sidebar="false" standardStylesheets="false">

   <apex:form >

    <label>
      Which high school do you attend?<br/>
    </label>

    <div>
        <apex:inputField value="{!Form__c.High_School_Attended__c}" />
    </div>  

   </apex:form>

</apex:page>

Here is the field. 

User-added image
Hi All,

Configuring Communties self registration. After submitting new user login info, I  am redirected to an "Internal server error..." message (screenshot attached).  I have properly (I hope) updated the SelfRegController --adding a profile, role and account ID. Deployed to production with 85% Coverage and no problems. Also, the new user is correctly added to salesforce. 

Is this a navigation issue, perhaps?

Thank you!