Salesforce

An effort to bring a revolution in Salesforce.

Thursday, 26 October 2017

Future method cannot be called from a future or batch method: Error

11:40

CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY

System.AsyncException: Future method cannot be called from a future.

System.AsyncException: Future method cannot be called from a future or batch method


You need to check if the trigger is being fired from the future method, add the below line as your first line of trigger.

    if(system.isFuture() || System.isBatch()) return;

Thursday, 6 April 2017

What is the formula to calculate the number of days between two dates?

11:00

Salesforce: Days between two dates

CreatedDate is not a Date datatype field it's a DateTime datatype, you need to convert it using a DATEVALUE function like this. 

Datatype = Formula
Result = Number 

TODAY () - DATEVALUE(CreatedDate) 

Error: Incorrect parameter for operator '-'. Expected Number, Date, received DateTime.


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');

Get Gmail, Docs, Drive, and Calendar for business