Thursday, 23 February 2017
Status=Length Required, StatusCode=411 error in Apex callout
13:48
Status=Length Required StatusCode=411
HttpRequest request = new HttpRequest();
request.setHeader('Content-Length', '512');
Thursday, 9 February 2017
Email To Opprtunity|Contact|Lead|Sobject Salesforce Email Service
17:00
Email To Opprtunity | Email To Sobject | Email To Contact | Salesforce Email Service
global class EmailtoOpportunityCreation implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
Messaging.InboundEnvelope envelope) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
System.debug('====> Created opportunity '+result);
Contact vCon;
for(Contact c: [Select Id, Name, Email, AccountId From Contact Where Email = :email.fromAddress Limit 1])
vCon = c;
if(vCon == null)
{
vCon = new Contact(lastname = 'Email-OPP',email = email.fromAddress);
insert vCon;
Account A = new Account(Name=email.Subject);
vCon.AccountId = a.id;
update vCon;
}
Opportunity opportunity = new Opportunity();
opportunity.Name = email.Subject;
opportunity.StageName = 'Prospecting';
opportunity.CloseDate = Date.today();
opportunity.Email_Body__c = email.plainTextBody;
//opportunity.Contact_Name__c = vCon.Id;
opportunity.AccountId = vCon.AccountId;
insert opportunity;
System.debug('====> Created opportunity '+opportunity.Id);
if (email.binaryAttachments != null && email.binaryAttachments.size() > 0) {
for (integer i = 0 ; i < email.binaryAttachments.size() ; i++) {
Attachment attachment = new Attachment();
// attach to the newly created opportunity record
attachment.ParentId = opportunity.Id;
attachment.Name = email.binaryAttachments[i].filename;
attachment.Body = email.binaryAttachments[i].body;
insert attachment;
}
}
return result;
}
}
Demo: Demo Link
Wednesday, 3 August 2016
How to read text file from static resource Salesforce.
19:00
Method to read Text File from static resource.
public String textFromSomeUniqueName {
get {
StaticResource sr = [
select Body
from StaticResource
where Name = 'SomeUniqueName'
];
return sr.Body.toString();
}
}
Subscribe to:
Posts (Atom)
