I have an APEX class with an @InvocableMethod which is executing from Process builder on Lead object,
I am trying to assign Owner for new lead based on round robin arrangement, but its throwing
My Code:
LOG:String lo=fetchLeadOwner(activeLOs);
System.debug('We chose ::'+lo+':: Based on less number of leads');
leadDetails.OwnerId = lo; // here getting System.FinalException: Record is read-only
update leadDetails;
USER_DEBUG|[15]|DEBUG|We chose ::0052h000000WhyWAAS:: Based on less number of leads
STATEMENT_EXECUTE|[16]
HEAP_ALLOCATE|[16]|Bytes:4
EXCEPTION_THROWN|[16]|System.FinalException: Record is read-only
HEAP_ALLOCATE|[16]|Bytes:23
FATAL_ERROR|System.FinalException: Record is read-only
2 件の回答
Did you query the lead record again in the Class? Process Builder acts like an after trigger in that the record is readonly.