You need to sign in to do that
Don't have an account?
SteveOrg93
Create activity after Lead Status is changed
Hi Everyone, I was hoping I could get some insights as to what might be wrong with my trigger. I have the following trigger I would like to run when a lead status within the lead is changed to a particular value. When the value is changed, I would like to create a new activity on the lead record.
Here is my code below, and the error I get back is:
Error: Compile Error: No access to entity: Activity at line 1 column 1
Any help would be greatly appreciated!
trigger createLeadActivity on Lead (after update) { //make a set to hold opportunity ids that we need Set<Id> leadIds = new Set<Id>(); for(Lead l : trigger.new) { //check to see if our field has been changed if(l.status != trigger.oldMap.get(l.Id).Status){ leadIds.add(l.Id); } } if(!leadIds.isEmpty()){ List<Lead> leadList = [SELECT Id,Status FROM Lead WHERE Status = '4 - SAL Engaged' AND Id IN :leadIds ]; for(Lead leadly: leadList){ Lead led = new Activity(); Activity newActivity = new Activity(Subject='LeadPassed',OwnerId=leadMap.get( record.WhoId ).OwnerId,Status='Not Started',Priority='Normal',WhoId=leadMap.get( record.WhoId ).id); ActList.add(newActivity); } } }
Hi Steve,
Yes Puja is correct. There is no object in the activity in salesforce. for that we can use Task or Event object.
for example in your trigger you used the following,
Activity newActivity = new Activity(Subject='LeadPassed',OwnerId=leadMap.get( record.WhoId ).OwnerId,
Status='Not Started',Priority='Normal',WhoId=leadMap.get( record.WhoId ).id);
Changed the above code like the following :
Task newActivity = new Task(Subject='LeadPassed',OwnerId=leadMap.get( record.WhoId ).OwnerId,
Status='Not Started',Priority='Normal',WhoId=leadMap.get( record.WhoId ).id);
and refer the following link for available salesforce standard objects :
http://www.salesforce.com/us/developer/docs/api/index_Left.htm#CSHID=sforce_api_objects_profile.htm|StartTopic=Content%2Fsforce_api_objects_profile.htm|SkinName=webhelp
All Answers
Hi,
In salesforce there is no such object with name "Activity" ,there is two objects related to Activity i.e. Event and task.
If you want to create any Activity,either you create a new task or new event.
Hi Steve,
Yes Puja is correct. There is no object in the activity in salesforce. for that we can use Task or Event object.
for example in your trigger you used the following,
Activity newActivity = new Activity(Subject='LeadPassed',OwnerId=leadMap.get( record.WhoId ).OwnerId,
Status='Not Started',Priority='Normal',WhoId=leadMap.get( record.WhoId ).id);
Changed the above code like the following :
Task newActivity = new Task(Subject='LeadPassed',OwnerId=leadMap.get( record.WhoId ).OwnerId,
Status='Not Started',Priority='Normal',WhoId=leadMap.get( record.WhoId ).id);
and refer the following link for available salesforce standard objects :
http://www.salesforce.com/us/developer/docs/api/index_Left.htm#CSHID=sforce_api_objects_profile.htm|StartTopic=Content%2Fsforce_api_objects_profile.htm|SkinName=webhelp