12
votes
Accepted
Trigger not updating field in Test Class
The error is in your Status. In the trigger you've got:
if (l.Status =='Open- Not Contacted')
(note the n- N), and in your test class you create it as:
ld.Status='Open -Not Contacted';
(note the n ...
11
votes
Accepted
Apex - Task.What.Type
You don't get cross-object fields in the trigger context. You would need to query for them. However, you can get the SObjectType instead and spare yourself the query.
if (T.WhatId != null && ...
11
votes
Accepted
Formula field is not working as expected
Assuming your formula was copied directly from salesforce.com, the problem has to do with "Smart Quotes." Salesforce formulas don't recognize “ and ” as actual quotation marks. Try using the following:...
8
votes
Accepted
Remove tabs from activities in lightning
For removing the actions in Lightning, Go to Setup->Object Manager then select the object. Go to page layouts and edit the Page layout currently assigned. Under "Salesforce Mobile and Lightning ...
7
votes
Accepted
Query and Follow Owner Relationship on Tasks
Yes, you need to use the TYPEOF operator. You can have multiple WHEN clauses in the SELECT, one for each valid type.
Example:
SELECT Id, Subject,
TYPEOF Owner
WHEN User THEN Owner.MyField__c
END
...
7
votes
Entity 'Task' is not supported for semi join inner selects
You need to split out a separate query. As the error states, you can't use this join:
Id NOT IN (Select WhatId from Task)
One possible approach to splitting out the query:
Set<Id> ...
6
votes
Accepted
get all task related to contact in developer console
You will need to SOQL Contact first then feed the Tasks List with those ContactIds to get the related Tasks.
Contact SOQL
Contact[] cons = [SELECT id from Contact ];
Now, feed these ContactIDs to ...
6
votes
Accepted
New Task Action missing in Lightning Experience
When viewing the Activity composer related list, you may notice that some activity actions within the lightning experience do not appear on records even though those actions have been added to the ...
6
votes
Accepted
How to use an Apex Email Service to store emails on a record EXACTLY as Salesforce does?
From what I understand, You don't need to create a task to insert an EmailMessage. Email message has relatedToId field which you can use to directly link it to any desired record. As relatedToId is ...
5
votes
No clean data columns available for custom fields - Erro while creating a new Custom Field
This sometimes occurs due to an error in the sandbox copying process.
You may attempt to resolve this by creating a new custom field on the object named in the install error, then delete it and then ...
5
votes
Prevent task deletion by anyone other than task creator
You need to write a delete trigger.
Validations should happen before delete.
You can get the Id of the running user via UserInfo.getUserId().
You can compare the CreatedById to the running user Id.
...
5
votes
Activities on Leads, Opportunities, and Accounts SOQL
The object you should query is OpenActivity and ActivityHistory
So your query should be
SELECT Report_Country_L__c,
(SELECT Owner.Name,ActivityDate,Status,istask,ActivitySubtype, Subject FROM ...
5
votes
Accepted
No such column 'Type' on entity 'LookedUpFromActivity'
If you look at LookedUpFromActivity object.
There is no Type field, instead you can use ActivityType or ActivitySubtype field
5
votes
Accepted
SOQL aggregate functions do not work with Task.ActivityDate
I have found a workaround by creating a custom field of type date under the Activity object called ActivityDate__c. Thus we can reformulate the initial query as
SELECT WhoID, COUNT(Id), MIN(...
5
votes
Accepted
Apex trigger not creating task
What is wrong with this specific code, why is it not creating a new task on the donation?
You didn't actually call the code that commits data to the database, as in:
insert taskList;
Which you ...
5
votes
Accepted
What happens when I delete the Task related to an EmailMessage?
Note: Some of the following is conclusions my team reached for which we could not find explicit documentation; Salesforce support eventually confirmed our findings, just this past week.
The ...
5
votes
Accepted
PrePopulate Task with related data even before creating a Task
Triggers are supposed to work that way. They do not pre-populate data on the screens but only update it during the transaction.
Out of the box, you will not be able to pre-populate data. If you can ...
5
votes
Accepted
"Variable does not exist: Type" when creating a Task
Usually this problem happens when the FLS is not enabled for the user's profile.
First thing to check in such cases is to create the record from Salesforce UI to verify if the field is visible.
4
votes
Cannot query UserRecordAccess for Tasks
Why?
The reason why is that activities are expensive to calculating sharing for. While this isn't called out in any manual I could find, I'm certain that's the reason. If you haven't noticed, ...
4
votes
Enabling Editing/Deleting others' Tasks without "Modify All"
There's no general "configuration-only" solution to this problem. You'll need a way to bypass sharing to allow deletion. Here's some choices (some of which are already noted in the comments):
Custom ...
4
votes
Task and Event in salesforce
Here, I have tried to show if opportunities are getting closed then it will search for any open tasks exists. If open task exists it will throw the error. Otherwise, you can proceed to call ...
4
votes
Accepted
Does the "Only" part of the "Due Date Only" label of Task.ActivityDate have some significance?
It seems likely we can attribute it to the linkage of Event and Task as Activities, and the fact that Event has a field called ActivityDateTime in addition to ActivityDate.
system.debug(Task....
4
votes
Trigger not updating field in Test Class
Among the other answers here you will still need to move this line to be after you insert your task.
Lead Getleadupdated = [SELECT Status FROM Lead where ID = : createlead.id];
Otherwise the value ...
4
votes
Accepted
How to stop workflow execution when Task Status is set to "Completed"?
You should include status not equal to Completed in the rule criteria.
Refer Will the pending actions in the queue ALWAYS trigger?
Time-dependent actions remain in the Workflow Queue until ...
4
votes
Populating Task Subtype field with Call when a task created
Task.TaskSubtype is createable, but not updateable. This means it's amenable to being populated only at the time of the record's creation, without firing an update DML operations. Practically, that ...
4
votes
Accepted
Activities past due dates are still displaying in Next Steps section in LEX
Yes, you'll notice the dates are highlighted in red, which indicates that they are open tasks that are past due. This same behavior happens in Classic as well on places where you can view open tasks (...
4
votes
How to Assign Enter Key to specific Button in vf page
I do not see any JS code on your page which is outlined in the reference you linked to and said you used so I am not sure how much more help this will be since it is essentially restating what was in ...
4
votes
Accepted
SOQL Query To Return Any Open Tasks Assigned To a User
You are retrieving information about the related Account but that doe not mean the Owner of the Task matches the Account Name.
SELECT Id, AccountId, Account.Name
FROM Task
WHERE Owner.Name = 'John ...
4
votes
Accepted
How to perform field update before a Validation Rule? (without code)
Combining a declarative field update with a validation rule is a creative idea. Some people would go right for code!
You're right about it being impossible though, since custom validation rules run ...
4
votes
Accepted
how to update lastmodified field whenever any user updated task
You can't write to LastModifiedById. Even if you could, this line
Plan.LastModifiedBy.Id = cop.Tasks.OwnerId
wouldn't work for a couple of reasons:
Changes to a related object (LastModifiedBy) don'...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
tasks × 564apex × 128
trigger × 68
activities × 63
soql × 46
visualforce × 38
workflow × 34
process-builder × 27
email × 25
event × 22
opportunity × 21
lightning × 20
lightning-experience × 18
visual-workflow × 15
case × 15
activity × 13
reporting × 12
account × 11
leads × 11
data-loader × 10
contact × 10
email-alert × 10
queue × 10
task-notifications × 10
formula × 9