Logo Activity And Task Patterns

Activity And Task Patterns

Cộng đồng
PranavNagrecha
activity-and-task-patterns

Task and Event objects: polymorphic WhatId/WhoId, Activity object model, ActivityHistory vs OpenActivity, activity timeline customization, bulk task creation, Einstein Activity Capture boundaries. NOT for turning on EAC or calendar sync — use admin/einstein-activity-capture-setup. NOT for Email-to-Case — use admin/case-management-setup. Covers ActivitiesSettings metadata, enableActivities, shared Task/Event custom fields and FLS, TaskStatus value sets, Shared Activities and TaskRelation/EventRelation, recurring and child activities, and partial-success bulk DML on Task.

Tổng quan

Nhà phát hànhPranavNagrecha
Kho mãAwesomeSalesforceSkills
Tên kỹ năngactivity-and-task-patterns
Sao
26
Bản fork
5
Tệp đi kèm
7
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 7 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được PranavNagrecha công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Activity And Task Patterns trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/PranavNagrecha/AwesomeSalesforceSkills/tree/main/skills/admin/activity-and-task-patterns
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/PranavNagrecha/AwesomeSalesforceSkills.git /tmp/AwesomeSalesforceSkills
mkdir -p .claude/skills
cp -r /tmp/AwesomeSalesforceSkills/skills/admin/activity-and-task-patterns .claude/skills/activity-and-task-patterns
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Activity And Task Patterns trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Activity And Task Patterns ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Activity And Task Patterns với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Activity and Task Patterns

Activate when designing interactions with Salesforce Activities — Task and Event records that attach to other objects via polymorphic WhatId and WhoId. The Activity object model is unusual: Activity is a read-only abstract parent, Task and Event are concrete children, and ActivityHistory / OpenActivity are read-only related lists, not queryable in bulk.

Before Starting

  • Understand the Activity object model. Activity cannot be queried directly; query Task or Event. ActivityHistory and OpenActivity appear on related lists and subqueries only.
  • Know the polymorphic fields. WhatId can reference any object enabled for activities; WhoId references Contact or Lead. Require TYPEOF or explicit type filters in SOQL.
  • Check Einstein Activity Capture. EAC-captured emails/events are stored outside standard Task/Event and are not reportable the same way.

Questions to Ask Before Configuring

Ask these before writing a line of Apex or opening Setup. Each one maps to a platform behaviour documented in references/gotchas.md; skipping them produces activity code that passes review and then misbehaves in production.

AskWhy it mattersWhat a good answer adds
"Is Shared Activities on in this org, and who turned it on?"It cannot be enabled or disabled by a deploy — allowUsersToRelateMultipleContactsToTasksAndEvents has been read-only in every API version since v36.0Whether TaskWhoIds, TaskRelation and multi-contact relates exist at all, before code assumes them
"Who owns these activities, and should each one email its owner?"Apex DML that creates or modifies a Task triggers the assignment notification by defaultA decision to set EmailHeader.triggerUserEmail, and a backfill that doesn't mail thousands of people
"What is the read path — which field will the WHERE clause filter on?"Subject, TaskStatus and TaskPriority are on the platform's can't-index list; WhatId / OwnerId / date ranges are notWhether Task/Event survives the volume, or the design needs a custom Interaction__c
"Does this field make sense on both a Task and an Event?"There is no Task-only custom field; Activity fields land on both children and share field-level securityThe validation rule that scopes it, and the FLS entries for both objects in the same deploy
"Are any of these activities recurring, or occurrences of a series?"Recurring Tasks can't be flipped after creation and reject ActivityDate/Status updates; child Events accept updates to IsReminderSet and ReminderDateTime onlyA partition step before the bulk DML instead of a half-failed job
"Is Einstein Activity Capture on for anyone here?"EAC-captured mail and events live outside the Task/Event tables, so reports and triggers silently miss themAn explicit source-of-truth statement in the data dictionary
"Can one bad row be allowed to fail on its own?"The bare insert verb rolls the whole transaction back; Database.insert(..., dmlOptions, ...) does notA partial-success write plus the Database.SaveResult loop that reports what didn't land

What a proper configuration adds over just creating the records: the activity model matches the org's actual read path and volume, the shared Task/Event surface is deployed as one unit instead of half of it silently disabling FLS, and bulk writes fail one row at a time and quietly instead of rolling back a 200-record save while emailing everyone.

Core Concepts

Task vs Event

Task: to-do item with due date. Event: calendar appointment with start/end time. Both share the polymorphic WhatId / WhoId pattern and an IsTask discriminator on Activity queries.

Polymorphic SOQL

SELECT Id, Subject, What.Type, TYPEOF What
  WHEN Account THEN Name, Industry
  WHEN Opportunity THEN Amount, StageName
END FROM Task

Without TYPEOF, only ID and Type are accessible via What.Type.

ActivityHistory vs OpenActivity

ActivityHistory: closed activities (completed tasks, past events). OpenActivity: open activities (due, upcoming). Only queryable as subqueries from activity-enabled parents. Cannot create/update these objects directly.

Einstein Activity Capture

EAC syncs emails and calendar events from Exchange/Gmail into Salesforce. Data lives in a separate EAC store — visible on timeline, but not in Task/Event tables. Reporting requires Activity Metrics or EAC-specific features.

Common Patterns

Pattern: Bulk task creation from trigger

apex
List<Task> tasks = new List<Task>();
for (Opportunity o : Trigger.new) {
    tasks.add(new Task(WhatId = o.Id, Subject = 'Review',
                       ActivityDate = Date.today().addDays(7), OwnerId = o.OwnerId));
}

Database.DMLOptions dml = new Database.DMLOptions();
dml.optAllOrNone = false;                  // one bad WhoId must not roll back the save
dml.EmailHeader.triggerUserEmail = false;  // suppress "a task was assigned to you"

List<Database.SaveResult> results =
    Database.insert(tasks, dml, AccessLevel.SYSTEM_MODE);

Collect and write once — never loop-DML. The two DMLOptions lines are not optional polish: creating or modifying a Task is one of the events that fires triggerUserEmail, and the bare insert verb has nowhere to put either setting. Full version with result handling in references/metadata-examples.md section 5.

Pattern: Custom Object for high-volume activity-like data

Past roughly 50k activities/day per object — UNVERIFIED (2026-09-05): a field heuristic, no activity-volume ceiling is published in the App Limits cheat sheet or the LDV guide — consider a custom Interaction__c with a real lookup instead of polymorphic Task. The grounded reason to switch is the read path, not the number: the LDV guide lists Activity Subject, TaskStatus and TaskPriority among the standard fields the platform can't index, so a query that must filter on any of them will not get selective on a large Task table.

Pattern: Activity rollup via Lightning component or Apex

Activity count / last-activity-date rollups: use formula-friendly patterns (e.g., Salesforce's Activity Metrics, EAC Insights, or DLRS).

Decision Guidance

NeedApproach
Standard to-do with remindersTask
Calendar appointment with participantsEvent
Query must filter on activity subject or status at volumeCustom Interaction__c with an indexed field
Email tracking without EACEmailMessage + Task linking
Reporting on email activityActivity Metrics or EAC Insights

Recommended Workflow

  1. Establish what the org already does. Retrieve Settings:Activities and check whether Shared Activities is on — it is a read-only field no deploy can change, and TaskWhoIds / TaskRelation / EventRelation.IsParent only exist when it is. Note whether Einstein Activity Capture is enabled for anyone (admin/einstein-activity-capture-setup).
  2. Decide Task/Event vs custom Interaction__c using the Decision Guidance table above and the tradeoff table in references/well-architected.md. Drive the decision from the read path and the sharing requirement, not from record count alone.
  3. Write the metadata from references/metadata-examples.md — Activities.settings-meta.xml, enableActivities on every object that must be a valid WhatId, the custom field under Activity (never under Task), the TaskStatus value set if IsClosed semantics are changing, and FLS entries for Task and Event in the same permission set.
  4. Write the read path with TYPEOF or a What.Type filter, and the write path with Database.insert(records, dmlOptions, accessLevel) carrying optAllOrNone = false and EmailHeader.triggerUserEmail = false. Partition out recurring Tasks and child Events (IsChild = true) before any bulk update.
  5. Lint the working tree with python3 skills/admin/activity-and-task-patterns/scripts/check_activity_and_task_patterns.py --manifest-dir force-app/main/default. It flags FROM Activity, DML on ActivityHistory/OpenActivity, loop-DML on Task/Event, What.<field> without TYPEOF, bare insert/update of Task collections, ActivitiesSettings files that try to set the read-only Shared Activities flag, and permission-set FLS that names one child object but not the other.
  6. Read references/gotchas.md end to end before deploying — the ten entries are the failures this skill exists to prevent, and several of them (the 500-row subquery cap, shared FLS, the EmailMessage task swap) are invisible in a sandbox with test-sized data.
  7. Verify in the target org using the three checks at the end of references/metadata-examples.md: a Task insert against the newly activity-enabled object, a Status/IsClosed/CompletedDateTime query, and a FieldPermissions query that must return a row for both Task.<field> and Event.<field>.

Review Checklist

  • Activity volume estimated and matched to object choice
  • Polymorphic SOQL uses TYPEOF or explicit type filters
  • Bulk DML used for task/event creation
  • ActivityHistory / OpenActivity queries only in subquery form
  • EAC data strategy documented
  • Custom fields on Activity limited (they propagate to both Task and Event)
  • Sharing model for activities understood (inherits from WhatId parent)
  • FLS deployed for Task.<field> and Event.<field> — a missing entry disables, it does not preserve
  • Bulk writes use Database.insert(..., dmlOptions, accessLevel) with optAllOrNone = false
  • EmailHeader.triggerUserEmail set deliberately on any job that creates or modifies Tasks
  • Recurring Tasks and IsChild = true Events partitioned out before bulk update
  • Shared Activities state confirmed in the org, not assumed from a deploy
  • WHERE clauses filter on an indexable field, not Subject / Status / Priority alone
  • scripts/check_activity_and_task_patterns.py --manifest-dir … run clean

Salesforce-Specific Gotchas

  1. Custom fields on Activity propagate to both Task and Event. You cannot add a field only to Task — architect with this in mind.
  2. Activities inherit sharing from the WhatId parent. No independent sharing rules.
  3. OpenActivity and ActivityHistory cannot be modified. They are projections of Task/Event — the Object Reference lists describeSObjects() as their only supported call (object_reference.txt L23515–L23516, L191459–L191460).
  4. Shared Activities is not deployable. Its ActivitiesSettings field has been read-only in every API version since v36.0; a deploy that sets it succeeds and changes nothing.
  5. Task.IsClosed is never written directly. It is derived from the Status value's closed flag in the TaskStatus standard value set, and Event has no Status at all.

The ten platform behaviours behind these — with what happens, when, and how to avoid — are in references/gotchas.md.

Output Artifacts

ArtifactDescription
Activity model decisionTask vs Event vs custom object
SOQL pattern libraryPolymorphic queries with TYPEOF
Bulk creation templateApex trigger / batch pattern

Reference Files

FileRead it when
references/metadata-examples.mdWriting the deployable XML — ActivitiesSettings, enableActivities, an Activity custom field and its FLS, TaskStatus, plus the bulk-safe Apex and the post-deploy verification queries
references/gotchas.mdBefore deploying, and whenever activity behaviour differs between sandbox and production
references/examples.mdTwo worked scenarios end to end: a polymorphic timeline query for an LWC, and bulk task generation from a record-triggered context
references/llm-anti-patterns.mdReviewing AI-generated Apex or metadata that touches Task, Event or Activity
references/well-architected.mdChoosing between Task/Event and a custom Interaction__c, and citing the sources behind any claim in this skill

Related Skills

  • apex/apex-polymorphic-soql — TYPEOF, What.Type and instanceof in depth
  • apex/apex-dml-patterns — Database.DMLOptions beyond the email header, and partial-success result handling
  • apex/trigger-framework — where activity-creating logic belongs in a handler
  • admin/einstein-activity-capture-setup — EAC sync scope, and where EAC data actually lives
  • admin/case-management-setup — case-related activity handling
  • admin/email-to-case-configuration — the intake side of the EmailMessage.ActivityId task
  • admin/picklist-and-value-sets — standard vs global value sets, for the TaskStatus change
  • admin/queues-and-public-groups — Task.OwnerId accepts Groups of type Queue only
  • architect/large-data-volume-architecture — when activity volume forces a custom object
  • data/data-archival-strategies — what to do with IsArchived activities

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Activity And Task Patterns làm được gì?

Task and Event objects: polymorphic WhatId/WhoId, Activity object model, ActivityHistory vs OpenActivity, activity timeline customization, bulk task creation, Einstein Activity Capture boundaries. NOT for turning on EAC or calendar sync — use admin/einstein-activity-capture-setup. NOT for Email-to-Case — use admin/case-management-setup. Covers ActivitiesSettings metadata, enableActivities, shared Task/Event custom fields and FLS, TaskStatus value sets, Shared Activities and TaskRelation/EventRelation, recurring and child activities, and partial-success bulk DML on Task.

Vì sao nên dùng Activity And Task Patterns trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Activity And Task Patterns là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Activity And Task Patterns trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/PranavNagrecha/AwesomeSalesforceSkills/tree/main/skills/admin/activity-and-task-patterns. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Activity And Task Patterns?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Activity And Task Patterns với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Activity And Task Patterns với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Activity And Task Patterns có miễn phí không?

Kỹ năng này được PranavNagrecha phát hành trên GitHub. Hãy xem điều khoản giấy phép trong kho mã. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇