You need to sign in to do that
Don't have an account?
Timothy Winter
In the Bulk Apex Triggers Trailhead piece we are told to use WhatId to set the related field of a new task. However, when I look at the actual fields of the Task object the field name is actually What. When I try to use What I get an error. How would I have known to use the WhatId name instead and why is this in general?
Why do we use WHATID instead of the WHAT field on tasks?
In the Bulk Apex Triggers Trailhead piece we are told to use WhatId to set the related field of a new task. However, when I look at the actual fields of the Task object the field name is actually What. When I try to use What I get an error. How would I have known to use the WhatId name instead and why is this in general?
1) https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_task.htm
The WhatId represents nonhuman objects such as accounts, opportunities, campaigns, cases, or custom objects. WhatIds are polymorphic. Polymorphic means a WhatId is equivalent to the ID of a related object. The label is Related To ID.
The WhoId represents a human such as a lead or a contact. WhoIds are polymorphic. Polymorphic means a WhoId is equivalent to a contact’s ID or a lead’s ID. The label isName ID.
If Shared Activities is enabled, the value of this field is the ID of the related lead or primary contact. If you add, update, or remove the WhoId field, you might encounter problems with triggers, workflows, and data validation rules that are associated with the record. The label is Name ID.
Let us know if this will help you
All Answers
1) https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_task.htm
The WhatId represents nonhuman objects such as accounts, opportunities, campaigns, cases, or custom objects. WhatIds are polymorphic. Polymorphic means a WhatId is equivalent to the ID of a related object. The label is Related To ID.
The WhoId represents a human such as a lead or a contact. WhoIds are polymorphic. Polymorphic means a WhoId is equivalent to a contact’s ID or a lead’s ID. The label isName ID.
If Shared Activities is enabled, the value of this field is the ID of the related lead or primary contact. If you add, update, or remove the WhoId field, you might encounter problems with triggers, workflows, and data validation rules that are associated with the record. The label is Name ID.
Let us know if this will help you
For all the standard objects for the look up data type fields we need to append 'Id' additionally or else you cannot populate that field which will throw the error.
Examples:
owner --> ownerId
Account --> accountId
------------
Thanks,
Srinivas
- Please mark as solution if your problem is resolved.
I really appreciate the help on this topic!
1) https://developer.salesforce.com/docs/atlas.en-us.aapi.meta/api/sforce_api_objects_list.htm