SuperAPI AI Directory

salesforce

Marketing & growth

View repository

Updated 10-15 20:32

About this skill

Salesforce Operations Skill

Salesforce CLI (sf) to perform data operations, analysis, and management for the connected org.

Initial Setup

Before using this skill,references/org-config.md must be created to configure organization-specific information.

org-config.md Template

# Org 設定

| 項目 | 値 |
|------|-----|
| Instance URL | https://your-org.my.salesforce.com |
| API Version | 63.0 |
| Alias | your-alias |
| Default User | user@example.com |

Business Context

(Describe the business overview of this org. Examples: sales management for a SaaS product, order management for manufacturing, etc.)


設定ファイルが存在しない場合は、ユーザーに作成を案内すること。

## 接続とアーキテクチャ

### 認証の確認

操作を始める前に、まず接続状態を確認する。

```bash
sf org display --json
  • If a default org is already configured, use it as is
  • If the connection is lost, sf org login web to guide browser authentication
  • If no default org is configured, ask the user what to do

How to Use Commands Appropriately

The Salesforce CLI has two main data access methods. Use them appropriately depending on the situation.

  • sf data query — Executes a SOQL query.--json flag to retrieve structured data. Results are stored in .result.records and stored in
  • sf api request rest — Direct REST API invocation. Used for describe (metadata retrieval) and Tooling API calls. Note that the result format differs (arrays and objects are returned directly)

Depending on the org, there are constraints where some sObject types (ApexClass, Organization, etc.) cannot be accessed via SOQL. If metadata is needed, use the REST API /sobjects/<Object>/describe .

Data Model

references/org-schema.md lists the field list, picklist values, and relationships for each object. Refer to it when building SOQL queries or creating records.

If the schema file has not been created,sf api request rest /services/data/vXX.0/sobjects/<Object>/describe to retrieve metadata and assist with its creation.

Account Registration Rules

Standard Fields at Registration

When creating a new account, fill in the following fields as much as possible:

Field API Name Importance Research Method
Account Name Name ◎Required Official name (including legal entity designation)
Website Website ○Recommended Official site URL
Billing Address BillingStreet/City/State/PostalCode/Country ○Recommended Head office location
Phone Number Phone ○Recommended Main phone number
Industry Industry ○Recommended The most suitable value from the picklist values

Note: If the org has custom required fields, references/org-schema.md Refer to and handle accordingly.

Confirming the official name

Always register the company name using its official name, including either the "prefixed form" (株式会社〇〇) or the "suffixed form" (〇〇株式会社). If the user provides an abbreviated name or a name without 株式会社, investigate the official name using WebSearch.

Duplicate check

Before registering, always check for duplicates with existing accounts:

sf data query --query "SELECT Id, Name FROM Account ORDER BY Name" --json

If the same company appears multiple times in the user's list, exclude the duplicates, and report to the user that companies already registered will be skipped.

Bulk registration procedure

When registering multiple accounts at once:

  1. Receive the list of company names from the user
  2. Duplicate check (cross-check with existing accounts + remove duplicates within the list)
  3. Investigate each company's official name and prefixed/suffixed form using WebSearch
  4. Investigate the website, head office address, and main phone number using WebSearch
  5. Present the list of registration details in a Markdown table and obtain the user's approval
  6. After approval,sf data create record register with (execute in parallel, 5 at a time)
  7. Display the registration results with a final confirmation SOQL query
# 取引先作成の例
sf data create record --sobject Account --values "Name='株式会社サンプル' Website='https://www.example.co.jp/' BillingCity='千代田区' BillingState='東京都' BillingCountry='日本' Industry='Technology'" --json

Address field splitting rules

Field Content to store Example
BillingPostalCode Postal code (with hyphen) 102-0093
BillingCountry Country name 日本
BillingState Prefecture 東京都
BillingCity City/County (for designated cities, up to the ward) 千代田区 / 大阪市北区
BillingStreet Town name, street number, building name 平河町2-16-1 平河町森タワー

Opportunity registration rules

Opportunity naming convention

The opportunity naming convention differs for each org.references/org-config.md If a naming convention is described in, follow it. If not described, confirm with the user.

Opportunity registration flow from an inquiry

When registering an opportunity from inquiry information, process in bulk using the following steps:

  1. Account confirmation/registration: Search for an existing account, and if none exists, register a new one (following the account registration rules)
  2. Contact registration: Create a Contact and associate it with the account
  3. Opportunity creation: Create the opportunity following the naming convention
    • Check the org's stage values and set the initial stage
  4. Associating the contact: OpportunityContactRole Associate the opportunity with the contact (IsPrimary=true)
  5. Setting the owner: If specified, set the same owner (OwnerId) for the account, contact, and opportunity
# OpportunityContactRole の作成例
sf data create record --sobject OpportunityContactRole --values "OpportunityId='006XXXXXXXXXXXX' ContactId='003XXXXXXXXXXXX' IsPrimary=true" --json

Operation patterns

1. Data reference (SOQL query)

Execute SOQL queries with sf data query . Always --json attach to receive as structured data.

sf data query --query "SELECT Id, Name, StageName, Amount, CloseDate FROM Opportunity ORDER BY CloseDate DESC LIMIT 10" --json

Query tips:

  • Enclose Japanese values in single quotes (e.g., WHERE StageName = '05-受注')
  • When retrieving fields from related records, the REST API is more reliable:
    sf api request rest '/services/data/vXX.0/query?q=SELECT+Id,Name,Account.Name+FROM+Opportunity'
    
  • COUNT() Queries can also be used: SELECT count() FROM Opportunity WHERE IsClosed = false
  • For large amounts of data, LIMIT should be set appropriately

Processing results: sf data query --json results have the following structure:

{
  "status": 0,
  "result": {
    "records": [...],
    "totalSize": 10,
    "done": true
  }
}

2. Record creation

Record creation must always be confirmed with the user before execution. Display the content to be created in advance and obtain approval.

sf data create record --sobject Account --values "Name='新規取引先'" --json

For multiple fields, pass them to --values separated by spaces. For reference fields (lookup/master-detail), specify the ID.

3. Record update

Record updates also must always be confirmed with the user before execution. Display both the value before the change and the value after the change.

sf data update record --sobject Opportunity --record-id 006XXXXXXXXXXXX --values "StageName='Closed Won'" --json

For stage changes: When changing the opportunity stage, also display the current stage. For valid stage values, refer to references/org-schema.md .

4. Record deletion

Record deletion with particular caution must be confirmed. Display the details of the record to be deleted in detail, explain the impact on related records, and then obtain explicit approval.

sf data delete record --sobject Account --record-id 001XXXXXXXXXXXX --json

5. Bulk operations

For operations on multiple records, bulk operations using CSV are efficient.

# CSVからインポート
sf data import tree --sobject Account --files /path/to/accounts.json --json

# バルクアップサート
sf data upsert bulk --sobject Account --file /path/to/accounts.csv --external-id Id --json

Since bulk operations have a large impact, always specify the target number of records and the operation content in advance.

Report and analysis patterns

When the user requests a report or analysis, retrieve the data with SOQL, format it, and display it.

Pipeline report

# 進行中の商談一覧
sf data query --query "SELECT Id, Name, StageName, Amount, CloseDate, Account.Name FROM Opportunity WHERE IsClosed = false ORDER BY CloseDate" --json

Group the results by stage and also display a summary of the amounts.

Project status report

When using a custom object, refer to the field definitions of references/org-schema.md and assemble the query.

Metadata operations

Use describe to check the field list and relationships of an object.

sf api request rest /services/data/vXX.0/sobjects/Opportunity/describe

From the results, retrieve the fields array, and refer toname, label, type, picklistValues , etc.

API Versionは references/org-config.md Use the value described in . If not set, use the latest version.

Safety guidelines

  • Reference operations (query/describe) may be executed freely based on the user's instructions
  • Create and update operations must always display the content and obtain the user's approval before execution
  • Delete operations require a sufficient explanation of the impact and execution only after obtaining explicit approval
  • Bulk operations require the target number of records and operation content to be specified in advance and approval to be obtained
  • For production orgs, handle large-scale changes and metadata changes with particular caution
  • Be careful not to include access tokens or sensitive information in the output

Output format

  • Format and display list data as a Markdown table
  • Display amounts in Japanese yen (¥) with 3-digit comma separators
  • Display dates in the YYYY/MM/DD format
  • If there are many records, display a summary first and expand details as needed
  • In addition to the SOQL query execution results, add business interpretations and insights to the extent possible