@salesforce/webapp-template-feature-react-global-search-experimental 1.112.2 → 1.112.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.a4drules/skills/deploying-to-salesforce/SKILL.md +0 -2
- package/dist/.a4drules/skills/using-salesforce-data/SKILL.md +164 -69
- package/dist/.a4drules/skills/using-salesforce-data/graphql-search.sh +139 -0
- package/dist/.a4drules/webapp-data.md +353 -0
- package/dist/.a4drules/webapp-ui.md +16 -0
- package/dist/CHANGELOG.md +22 -0
- package/dist/force-app/main/default/webapplications/feature-react-global-search/package.json +3 -3
- package/dist/package-lock.json +2 -2
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: deploying-to-salesforce
|
|
3
3
|
description: Enforces the correct order for deploying metadata, assigning permission sets, and fetching GraphQL schema. Use for ANY deployment to a Salesforce org — webapps, LWC, Aura, Apex, metadata, schema fetch, or org sync. Codifies setup-cli.mjs.
|
|
4
|
-
paths:
|
|
5
|
-
- "**/*"
|
|
6
4
|
---
|
|
7
5
|
|
|
8
6
|
# Deploying to Salesforce
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: using-salesforce-data
|
|
3
|
-
description: Salesforce data access for
|
|
4
|
-
paths:
|
|
5
|
-
- "**/*.ts"
|
|
6
|
-
- "**/*.tsx"
|
|
7
|
-
- "**/*.graphql"
|
|
3
|
+
description: Salesforce data access for reading, writing, and querying records via REST, GraphQL, Apex, or Platform SDK. Use when the user wants to fetch, search, filter, sort, display, create, update, delete, or attach files to Salesforce records (standard objects like Accounts, Contacts, Opportunities, Cases, Quotes, or any custom object) in a web app or UI component (React, Angular, Vue, etc.); call Chatter, Connect, or Apex REST APIs; or invoke AuraEnabled Apex methods from an external app. Does not apply to authentication/OAuth setup, schema changes (adding fields, relationships), Bulk/Tooling/Metadata API usage, declarative automation (Flows, Process Builder), general LWC/Apex coding guidance without a specific data operation, or Salesforce admin/configuration tasks.
|
|
8
4
|
---
|
|
9
5
|
|
|
10
6
|
# Salesforce Data Access
|
|
@@ -16,7 +12,7 @@ Use this skill when the user wants to:
|
|
|
16
12
|
- **Fetch or display Salesforce data** — Query records (Account, Contact, Opportunity, custom objects) to show in a component
|
|
17
13
|
- **Create, update, or delete records** — Perform mutations on Salesforce data
|
|
18
14
|
- **Add data fetching to a component** — Wire up a React component to Salesforce data
|
|
19
|
-
- **Call REST APIs** — Use
|
|
15
|
+
- **Call REST APIs** — Use Connect REST, Apex REST, or UI API endpoints
|
|
20
16
|
- **Explore the org schema** — Discover available objects, fields, or relationships
|
|
21
17
|
|
|
22
18
|
## Data SDK Requirement
|
|
@@ -31,18 +27,38 @@ const sdk = await createDataSDK();
|
|
|
31
27
|
// GraphQL for record queries/mutations (PREFERRED)
|
|
32
28
|
const response = await sdk.graphql?.<ResponseType>(query, variables);
|
|
33
29
|
|
|
34
|
-
// REST for
|
|
35
|
-
const res = await sdk.fetch?.("/services/
|
|
30
|
+
// REST for Connect REST, Apex REST, UI API (when GraphQL insufficient)
|
|
31
|
+
const res = await sdk.fetch?.("/services/apexrest/my-resource");
|
|
36
32
|
```
|
|
37
33
|
|
|
38
34
|
**Always use optional chaining** (`sdk.graphql?.()`, `sdk.fetch?.()`) — these methods may be undefined in some surfaces.
|
|
39
35
|
|
|
36
|
+
## Supported APIs
|
|
37
|
+
|
|
38
|
+
**Only the following APIs are permitted.** Any endpoint not listed here must not be used.
|
|
39
|
+
|
|
40
|
+
| API | Method | Endpoints / Use Case |
|
|
41
|
+
|-----|--------|----------------------|
|
|
42
|
+
| GraphQL | `sdk.graphql` | All record queries and mutations via `uiapi { }` namespace |
|
|
43
|
+
| UI API REST | `sdk.fetch` | `/services/data/v{ver}/ui-api/records/{id}` — record metadata when GraphQL is insufficient |
|
|
44
|
+
| Apex REST | `sdk.fetch` | `/services/apexrest/{resource}` — custom server-side logic, aggregates, multi-step transactions |
|
|
45
|
+
| Connect REST | `sdk.fetch` | `/services/data/v{ver}/connect/file/upload/config` — file upload config |
|
|
46
|
+
| Einstein LLM | `sdk.fetch` | `/services/data/v{ver}/einstein/llm/prompt/generations` — AI text generation |
|
|
47
|
+
|
|
48
|
+
**Not supported:**
|
|
49
|
+
|
|
50
|
+
- **Enterprise REST query endpoint** (`/services/data/v*/query` with SOQL) — blocked at the proxy level. Use GraphQL for record reads; use Apex REST if server-side SOQL aggregates are required.
|
|
51
|
+
- **Aura-enabled Apex** (`@AuraEnabled`) — an LWC/Aura pattern with no invocation path from React webapps.
|
|
52
|
+
- **Chatter API** (`/chatter/users/me`) — use `uiapi { currentUser { ... } }` in a GraphQL query instead.
|
|
53
|
+
- **Any other Salesforce REST endpoint** not listed in the supported table above.
|
|
54
|
+
|
|
40
55
|
## Decision: GraphQL vs REST
|
|
41
56
|
|
|
42
57
|
| Need | Method | Example |
|
|
43
58
|
|------|--------|---------|
|
|
44
59
|
| Query/mutate records | `sdk.graphql` | Account, Contact, custom objects |
|
|
45
|
-
|
|
|
60
|
+
| Current user info | `sdk.graphql` | `uiapi { currentUser { Id Name { value } } }` |
|
|
61
|
+
| UI API record metadata | `sdk.fetch` | `/ui-api/records/{id}` |
|
|
46
62
|
| Connect REST | `sdk.fetch` | `/connect/file/upload/config` |
|
|
47
63
|
| Apex REST | `sdk.fetch` | `/services/apexrest/auth/login` |
|
|
48
64
|
| Einstein LLM | `sdk.fetch` | `/einstein/llm/prompt/generations` |
|
|
@@ -55,32 +71,36 @@ const res = await sdk.fetch?.("/services/data/v65.0/chatter/users/me");
|
|
|
55
71
|
|
|
56
72
|
### Step 1: Acquire Schema
|
|
57
73
|
|
|
58
|
-
The `schema.graphql` file (265K+ lines) is the source of truth. **
|
|
74
|
+
The `schema.graphql` file (265K+ lines) is the source of truth. **Never open or parse it directly.**
|
|
59
75
|
|
|
60
76
|
1. Check if `schema.graphql` exists at the SFDX project root
|
|
61
77
|
2. If missing, run from the **webapp dir**: `npm run graphql:schema`
|
|
62
78
|
3. Custom objects appear only after metadata is deployed
|
|
63
79
|
|
|
64
|
-
### Step 2:
|
|
80
|
+
### Step 2: Look Up Entity Schema
|
|
65
81
|
|
|
66
|
-
Map user intent to PascalCase names ("accounts" → `Account`)
|
|
82
|
+
Map user intent to PascalCase names ("accounts" → `Account`), then **run the search script from the project root**:
|
|
67
83
|
|
|
68
84
|
```bash
|
|
69
|
-
# From project root —
|
|
70
|
-
|
|
85
|
+
# From project root — look up all relevant schema info for one or more entities
|
|
86
|
+
bash .a4drules/skills/using-salesforce-data/graphql-search.sh Account
|
|
71
87
|
|
|
72
|
-
#
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
# Find mutation input
|
|
76
|
-
grep -nE '^input AccountCreateInput' ./schema.graphql -A 50
|
|
88
|
+
# Multiple entities at once
|
|
89
|
+
bash .a4drules/skills/using-salesforce-data/graphql-search.sh Account Contact Opportunity
|
|
77
90
|
```
|
|
78
91
|
|
|
79
|
-
|
|
92
|
+
The script outputs five sections per entity:
|
|
93
|
+
1. **Type definition** — all queryable fields and relationships
|
|
94
|
+
2. **Filter options** — available fields for `where:` conditions
|
|
95
|
+
3. **Sort options** — available fields for `orderBy:`
|
|
96
|
+
4. **Create input** — fields accepted by create mutations
|
|
97
|
+
5. **Update input** — fields accepted by update mutations
|
|
98
|
+
|
|
99
|
+
Use this output to determine exact field names before writing any query or mutation. **Maximum 2 script runs.** If the entity still can't be found, ask the user — the object may not be deployed.
|
|
80
100
|
|
|
81
101
|
### Step 3: Generate Query
|
|
82
102
|
|
|
83
|
-
Use the templates below. Every field name **must** be verified
|
|
103
|
+
Use the templates below. Every field name **must** be verified from the script output in Step 2.
|
|
84
104
|
|
|
85
105
|
#### Read Query Template
|
|
86
106
|
|
|
@@ -131,31 +151,109 @@ mutation CreateAccount($input: AccountCreateInput!) {
|
|
|
131
151
|
- Update: Include `Id`, only `updateable` fields
|
|
132
152
|
- Delete: Include `Id` only
|
|
133
153
|
|
|
154
|
+
#### Object Metadata & Picklist Values
|
|
155
|
+
|
|
156
|
+
Use `uiapi { objectInfos(...) }` to fetch field metadata or picklist values. Pass **either** `apiNames` or `objectInfoInputs` — never both in the same query.
|
|
157
|
+
|
|
158
|
+
**Object metadata** (field labels, data types, CRUD flags):
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
const GET_OBJECT_INFO = gql`
|
|
162
|
+
query GetObjectInfo($apiNames: [String!]!) {
|
|
163
|
+
uiapi {
|
|
164
|
+
objectInfos(apiNames: $apiNames) {
|
|
165
|
+
ApiName
|
|
166
|
+
label
|
|
167
|
+
labelPlural
|
|
168
|
+
fields {
|
|
169
|
+
ApiName
|
|
170
|
+
label
|
|
171
|
+
dataType
|
|
172
|
+
updateable
|
|
173
|
+
createable
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
`;
|
|
179
|
+
|
|
180
|
+
const sdk = await createDataSDK();
|
|
181
|
+
const response = await sdk.graphql?.(GET_OBJECT_INFO, { apiNames: ["Account"] });
|
|
182
|
+
const objectInfos = response?.data?.uiapi?.objectInfos ?? [];
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Picklist values** (use `objectInfoInputs` + `... on PicklistField` inline fragment):
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
const GET_PICKLIST_VALUES = gql`
|
|
189
|
+
query GetPicklistValues($objectInfoInputs: [ObjectInfoInput!]!) {
|
|
190
|
+
uiapi {
|
|
191
|
+
objectInfos(objectInfoInputs: $objectInfoInputs) {
|
|
192
|
+
ApiName
|
|
193
|
+
fields {
|
|
194
|
+
ApiName
|
|
195
|
+
... on PicklistField {
|
|
196
|
+
picklistValuesByRecordTypeIDs {
|
|
197
|
+
recordTypeID
|
|
198
|
+
picklistValues {
|
|
199
|
+
label
|
|
200
|
+
value
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
`;
|
|
209
|
+
|
|
210
|
+
const response = await sdk.graphql?.(GET_PICKLIST_VALUES, {
|
|
211
|
+
objectInfoInputs: [{ objectApiName: "Account" }],
|
|
212
|
+
});
|
|
213
|
+
const fields = response?.data?.uiapi?.objectInfos?.[0]?.fields ?? [];
|
|
214
|
+
```
|
|
215
|
+
|
|
134
216
|
### Step 4: Validate & Test
|
|
135
217
|
|
|
136
218
|
1. **Lint**: `npx eslint <file>` from webapp dir
|
|
137
219
|
2. **Test**: Ask user before testing. For mutations, request input values — never fabricate data.
|
|
138
220
|
|
|
221
|
+
**If ESLint reports a GraphQL error** (e.g. `Cannot query field`, `Unknown type`, `Unknown argument`), the field or type name is wrong. Re-run the schema search script to find the correct name — do not guess:
|
|
222
|
+
|
|
139
223
|
```bash
|
|
140
|
-
# From project root
|
|
141
|
-
|
|
142
|
-
--method POST \
|
|
143
|
-
--body '{"query":"..."}'
|
|
224
|
+
# From project root — re-check the entity that caused the error
|
|
225
|
+
bash .a4drules/skills/using-salesforce-data/graphql-search.sh <EntityName>
|
|
144
226
|
```
|
|
145
227
|
|
|
228
|
+
Then fix the query using the exact names from the script output.
|
|
229
|
+
|
|
146
230
|
---
|
|
147
231
|
|
|
148
232
|
## Webapp Integration (React)
|
|
149
233
|
|
|
150
|
-
### Pattern 1: External .graphql File (Recommended)
|
|
151
|
-
|
|
152
234
|
```typescript
|
|
153
|
-
import { createDataSDK,
|
|
154
|
-
|
|
155
|
-
|
|
235
|
+
import { createDataSDK, gql } from "@salesforce/sdk-data";
|
|
236
|
+
|
|
237
|
+
const GET_ACCOUNTS = gql`
|
|
238
|
+
query GetAccounts {
|
|
239
|
+
uiapi {
|
|
240
|
+
query {
|
|
241
|
+
Account(first: 10) {
|
|
242
|
+
edges {
|
|
243
|
+
node {
|
|
244
|
+
Id
|
|
245
|
+
Name @optional { value }
|
|
246
|
+
Industry @optional { value }
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
`;
|
|
156
254
|
|
|
157
255
|
const sdk = await createDataSDK();
|
|
158
|
-
const response = await sdk.graphql
|
|
256
|
+
const response = await sdk.graphql?.(GET_ACCOUNTS);
|
|
159
257
|
|
|
160
258
|
if (response?.errors?.length) {
|
|
161
259
|
throw new Error(response.errors.map(e => e.message).join("; "));
|
|
@@ -164,37 +262,16 @@ if (response?.errors?.length) {
|
|
|
164
262
|
const accounts = response?.data?.uiapi?.query?.Account?.edges?.map(e => e.node) ?? [];
|
|
165
263
|
```
|
|
166
264
|
|
|
167
|
-
After creating/modifying `.graphql` files, run: `npm run graphql:codegen`
|
|
168
|
-
|
|
169
|
-
### Pattern 2: Inline gql Tag
|
|
170
|
-
|
|
171
|
-
```typescript
|
|
172
|
-
import { createDataSDK, gql } from "@salesforce/sdk-data";
|
|
173
|
-
|
|
174
|
-
const GET_CURRENT_USER = gql`
|
|
175
|
-
query CurrentUser {
|
|
176
|
-
uiapi { currentUser { Id Name { value } } }
|
|
177
|
-
}
|
|
178
|
-
`;
|
|
179
|
-
|
|
180
|
-
const response = await sdk.graphql?.<CurrentUserQuery>(GET_CURRENT_USER);
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
**Must use `gql` tag** — plain template strings bypass ESLint validation.
|
|
184
|
-
|
|
185
265
|
---
|
|
186
266
|
|
|
187
267
|
## REST API Patterns
|
|
188
268
|
|
|
189
|
-
Use `sdk.fetch` when GraphQL is insufficient
|
|
269
|
+
Use `sdk.fetch` when GraphQL is insufficient. See the [Supported APIs](#supported-apis) table for the full allowlist.
|
|
190
270
|
|
|
191
271
|
```typescript
|
|
192
272
|
declare const __SF_API_VERSION__: string;
|
|
193
273
|
const API_VERSION = typeof __SF_API_VERSION__ !== "undefined" ? __SF_API_VERSION__ : "65.0";
|
|
194
274
|
|
|
195
|
-
// Chatter — current user
|
|
196
|
-
const res = await sdk.fetch?.(`/services/data/v${API_VERSION}/chatter/users/me`);
|
|
197
|
-
|
|
198
275
|
// Connect — file upload config
|
|
199
276
|
const res = await sdk.fetch?.(`/services/data/v${API_VERSION}/connect/file/upload/config`);
|
|
200
277
|
|
|
@@ -205,6 +282,9 @@ const res = await sdk.fetch?.("/services/apexrest/auth/login", {
|
|
|
205
282
|
headers: { "Content-Type": "application/json" },
|
|
206
283
|
});
|
|
207
284
|
|
|
285
|
+
// UI API — record with metadata (prefer GraphQL for simple reads)
|
|
286
|
+
const res = await sdk.fetch?.(`/services/data/v${API_VERSION}/ui-api/records/${recordId}`);
|
|
287
|
+
|
|
208
288
|
// Einstein LLM
|
|
209
289
|
const res = await sdk.fetch?.(`/services/data/v${API_VERSION}/einstein/llm/prompt/generations`, {
|
|
210
290
|
method: "POST",
|
|
@@ -212,6 +292,17 @@ const res = await sdk.fetch?.(`/services/data/v${API_VERSION}/einstein/llm/promp
|
|
|
212
292
|
});
|
|
213
293
|
```
|
|
214
294
|
|
|
295
|
+
**Current user**: Do not use Chatter (`/chatter/users/me`). Use GraphQL instead:
|
|
296
|
+
|
|
297
|
+
```typescript
|
|
298
|
+
const GET_CURRENT_USER = gql`
|
|
299
|
+
query CurrentUser {
|
|
300
|
+
uiapi { currentUser { Id Name { value } } }
|
|
301
|
+
}
|
|
302
|
+
`;
|
|
303
|
+
const response = await sdk.graphql?.(GET_CURRENT_USER);
|
|
304
|
+
```
|
|
305
|
+
|
|
215
306
|
---
|
|
216
307
|
|
|
217
308
|
## Directory Structure
|
|
@@ -222,47 +313,51 @@ const res = await sdk.fetch?.(`/services/data/v${API_VERSION}/einstein/llm/promp
|
|
|
222
313
|
├── sfdx-project.json
|
|
223
314
|
└── force-app/main/default/webapplications/<app-name>/ ← webapp dir
|
|
224
315
|
├── package.json ← npm scripts
|
|
225
|
-
├── codegen.yml
|
|
226
316
|
└── src/
|
|
227
|
-
└── api/graphql-operations-types.ts ← generated types
|
|
228
317
|
```
|
|
229
318
|
|
|
230
319
|
| Command | Run From | Why |
|
|
231
320
|
|---------|----------|-----|
|
|
232
321
|
| `npm run graphql:schema` | webapp dir | Script in webapp's package.json |
|
|
233
|
-
| `npm run graphql:codegen` | webapp dir | Reads codegen.yml |
|
|
234
322
|
| `npx eslint <file>` | webapp dir | Reads eslint.config.js |
|
|
235
|
-
| `
|
|
323
|
+
| `bash .a4drules/skills/using-salesforce-data/graphql-search.sh <Entity>` | project root | Schema lookup |
|
|
236
324
|
| `sf api request rest` | project root | Needs sfdx-project.json |
|
|
237
325
|
|
|
238
326
|
---
|
|
239
327
|
|
|
240
328
|
## Quick Reference
|
|
241
329
|
|
|
242
|
-
###
|
|
330
|
+
### Schema Lookup (from project root)
|
|
331
|
+
|
|
332
|
+
Run the search script to get all relevant schema info in one step:
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
bash .a4drules/skills/using-salesforce-data/graphql-search.sh <EntityName>
|
|
336
|
+
```
|
|
243
337
|
|
|
244
|
-
|
|
|
245
|
-
|
|
246
|
-
|
|
|
247
|
-
|
|
|
248
|
-
|
|
|
249
|
-
|
|
|
250
|
-
|
|
|
338
|
+
| Script Output Section | Used For |
|
|
339
|
+
|-----------------------|----------|
|
|
340
|
+
| Type definition | Field names, parent/child relationships |
|
|
341
|
+
| Filter options | `where:` conditions |
|
|
342
|
+
| Sort options | `orderBy:` |
|
|
343
|
+
| CreateRepresentation | Create mutation field list |
|
|
344
|
+
| UpdateRepresentation | Update mutation field list |
|
|
251
345
|
|
|
252
346
|
### Error Categories
|
|
253
347
|
|
|
254
348
|
| Error Contains | Resolution |
|
|
255
349
|
|----------------|------------|
|
|
350
|
+
| `Cannot query field` | Field name is wrong — run `graphql-search.sh <Entity>` and use the exact name from the Type definition section |
|
|
351
|
+
| `Unknown type` | Type name is wrong — run `graphql-search.sh <Entity>` to confirm the correct PascalCase entity name |
|
|
352
|
+
| `Unknown argument` | Argument name is wrong — run `graphql-search.sh <Entity>` and check Filter or OrderBy sections |
|
|
256
353
|
| `invalid syntax` | Fix syntax per error message |
|
|
257
|
-
| `validation error` |
|
|
354
|
+
| `validation error` | Field name is wrong — run `graphql-search.sh <Entity>` to verify |
|
|
258
355
|
| `VariableTypeMismatch` | Correct argument type from schema |
|
|
259
356
|
| `invalid cross reference id` | Entity deleted — ask for valid Id |
|
|
260
357
|
|
|
261
358
|
### Checklist
|
|
262
359
|
|
|
263
|
-
- [ ] All field names verified via
|
|
360
|
+
- [ ] All field names verified via search script (Step 2)
|
|
264
361
|
- [ ] `@optional` applied to record fields (reads)
|
|
265
362
|
- [ ] Optional chaining in consuming code
|
|
266
|
-
- [ ] `gql` tag used (not plain strings)
|
|
267
363
|
- [ ] Lint passes: `npx eslint <file>`
|
|
268
|
-
- [ ] Types generated: `npm run graphql:codegen`
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# graphql-search.sh — Look up one or more Salesforce entities in schema.graphql.
|
|
3
|
+
#
|
|
4
|
+
# Run from the SFDX project root (where schema.graphql lives):
|
|
5
|
+
# bash .a4drules/skills/using-salesforce-data/graphql-search.sh Account
|
|
6
|
+
# bash .a4drules/skills/using-salesforce-data/graphql-search.sh Account Contact Opportunity
|
|
7
|
+
#
|
|
8
|
+
# Pass a custom schema path with -s / --schema:
|
|
9
|
+
# bash .a4drules/skills/using-salesforce-data/graphql-search.sh -s /path/to/schema.graphql Account
|
|
10
|
+
# bash .a4drules/skills/using-salesforce-data/graphql-search.sh --schema ./other/schema.graphql Account Contact
|
|
11
|
+
#
|
|
12
|
+
# Output sections per entity:
|
|
13
|
+
# 1. Type definition — all fields and relationships
|
|
14
|
+
# 2. Filter options — <Entity>_Filter input (for `where:`)
|
|
15
|
+
# 3. Sort options — <Entity>_OrderBy input (for `orderBy:`)
|
|
16
|
+
# 4. Create input — <Entity>CreateRepresentation (for create mutations)
|
|
17
|
+
# 5. Update input — <Entity>UpdateRepresentation (for update mutations)
|
|
18
|
+
|
|
19
|
+
SCHEMA="./schema.graphql"
|
|
20
|
+
|
|
21
|
+
# ── Argument parsing ─────────────────────────────────────────────────────────
|
|
22
|
+
|
|
23
|
+
while [[ $# -gt 0 ]]; do
|
|
24
|
+
case "$1" in
|
|
25
|
+
-s|--schema)
|
|
26
|
+
if [[ -z "${2-}" || "$2" == -* ]]; then
|
|
27
|
+
echo "ERROR: --schema requires a file path argument"
|
|
28
|
+
exit 1
|
|
29
|
+
fi
|
|
30
|
+
SCHEMA="$2"
|
|
31
|
+
shift 2
|
|
32
|
+
;;
|
|
33
|
+
--)
|
|
34
|
+
shift
|
|
35
|
+
break
|
|
36
|
+
;;
|
|
37
|
+
-*)
|
|
38
|
+
echo "ERROR: Unknown option: $1"
|
|
39
|
+
echo "Usage: bash $0 [-s <schema-path>] <EntityName> [EntityName2 ...]"
|
|
40
|
+
exit 1
|
|
41
|
+
;;
|
|
42
|
+
*)
|
|
43
|
+
break
|
|
44
|
+
;;
|
|
45
|
+
esac
|
|
46
|
+
done
|
|
47
|
+
|
|
48
|
+
if [ $# -eq 0 ]; then
|
|
49
|
+
echo "Usage: bash $0 [-s <schema-path>] <EntityName> [EntityName2 ...]"
|
|
50
|
+
echo "Example: bash $0 Account"
|
|
51
|
+
echo "Example: bash $0 Account Contact Opportunity"
|
|
52
|
+
echo "Example: bash $0 --schema /path/to/schema.graphql Account"
|
|
53
|
+
exit 1
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
if [ ! -f "$SCHEMA" ]; then
|
|
57
|
+
echo "ERROR: schema.graphql not found at $SCHEMA"
|
|
58
|
+
echo " Make sure you are running from the SFDX project root, or pass the path explicitly:"
|
|
59
|
+
echo " bash $0 --schema <path/to/schema.graphql> <EntityName>"
|
|
60
|
+
echo " If the file is missing entirely, generate it from the webapp dir:"
|
|
61
|
+
echo " cd force-app/main/default/webapplications/<app-name> && npm run graphql:schema"
|
|
62
|
+
exit 1
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
# ── Helper: extract lines from a grep match through the closing brace ────────
|
|
66
|
+
# Prints up to MAX_LINES lines after (and including) the first match of PATTERN.
|
|
67
|
+
# Uses a generous line count — blocks are always closed by a "}" line.
|
|
68
|
+
|
|
69
|
+
extract_block() {
|
|
70
|
+
local label="$1"
|
|
71
|
+
local pattern="$2"
|
|
72
|
+
local max_lines="$3"
|
|
73
|
+
|
|
74
|
+
local match
|
|
75
|
+
match=$(grep -nE "$pattern" "$SCHEMA" | head -1)
|
|
76
|
+
|
|
77
|
+
if [ -z "$match" ]; then
|
|
78
|
+
echo " (not found: $pattern)"
|
|
79
|
+
return
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
echo "### $label"
|
|
83
|
+
grep -E "$pattern" "$SCHEMA" -A "$max_lines" | \
|
|
84
|
+
awk '/^\}$/{print; exit} {print}' | \
|
|
85
|
+
head -n "$max_lines"
|
|
86
|
+
echo ""
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
# ── Main loop ────────────────────────────────────────────────────────────────
|
|
90
|
+
|
|
91
|
+
for ENTITY in "$@"; do
|
|
92
|
+
echo ""
|
|
93
|
+
echo "======================================================================"
|
|
94
|
+
echo " SCHEMA LOOKUP: $ENTITY"
|
|
95
|
+
echo "======================================================================"
|
|
96
|
+
echo ""
|
|
97
|
+
|
|
98
|
+
# 1. Type definition — all fields and relationships
|
|
99
|
+
extract_block \
|
|
100
|
+
"Type definition — fields and relationships" \
|
|
101
|
+
"^type ${ENTITY} implements Record" \
|
|
102
|
+
200
|
|
103
|
+
|
|
104
|
+
# 2. Filter input — used in `where:` arguments
|
|
105
|
+
extract_block \
|
|
106
|
+
"Filter options — use in where: { ... }" \
|
|
107
|
+
"^input ${ENTITY}_Filter" \
|
|
108
|
+
100
|
|
109
|
+
|
|
110
|
+
# 3. OrderBy input — used in `orderBy:` arguments
|
|
111
|
+
extract_block \
|
|
112
|
+
"Sort options — use in orderBy: { ... }" \
|
|
113
|
+
"^input ${ENTITY}_OrderBy" \
|
|
114
|
+
60
|
|
115
|
+
|
|
116
|
+
# 4. Create mutation inputs
|
|
117
|
+
extract_block \
|
|
118
|
+
"Create mutation wrapper — ${ENTITY}CreateInput" \
|
|
119
|
+
"^input ${ENTITY}CreateInput" \
|
|
120
|
+
10
|
|
121
|
+
|
|
122
|
+
extract_block \
|
|
123
|
+
"Create mutation fields — ${ENTITY}CreateRepresentation" \
|
|
124
|
+
"^input ${ENTITY}CreateRepresentation" \
|
|
125
|
+
100
|
|
126
|
+
|
|
127
|
+
# 5. Update mutation inputs
|
|
128
|
+
extract_block \
|
|
129
|
+
"Update mutation wrapper — ${ENTITY}UpdateInput" \
|
|
130
|
+
"^input ${ENTITY}UpdateInput" \
|
|
131
|
+
10
|
|
132
|
+
|
|
133
|
+
extract_block \
|
|
134
|
+
"Update mutation fields — ${ENTITY}UpdateRepresentation" \
|
|
135
|
+
"^input ${ENTITY}UpdateRepresentation" \
|
|
136
|
+
100
|
|
137
|
+
|
|
138
|
+
echo ""
|
|
139
|
+
done
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
# Salesforce Data Access
|
|
2
|
+
|
|
3
|
+
- **Fetch or display Salesforce data** — Query records (Account, Contact, Opportunity, custom objects) to show in a component
|
|
4
|
+
- **Create, update, or delete records** — Perform mutations on Salesforce data
|
|
5
|
+
- **Add data fetching to a component** — Wire up a React component to Salesforce data
|
|
6
|
+
- **Call REST APIs** — Use Connect REST, Apex REST, or UI API endpoints
|
|
7
|
+
- **Explore the org schema** — Discover available objects, fields, or relationships
|
|
8
|
+
|
|
9
|
+
## Data SDK Requirement
|
|
10
|
+
|
|
11
|
+
> **All Salesforce data access MUST use the Data SDK** (`@salesforce/sdk-data`). The SDK handles authentication, CSRF, and base URL resolution. Never use `fetch()` or `axios` directly.
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { createDataSDK, gql } from "@salesforce/sdk-data";
|
|
15
|
+
|
|
16
|
+
const sdk = await createDataSDK();
|
|
17
|
+
|
|
18
|
+
// GraphQL for record queries/mutations (PREFERRED)
|
|
19
|
+
const response = await sdk.graphql?.<ResponseType>(query, variables);
|
|
20
|
+
|
|
21
|
+
// REST for Connect REST, Apex REST, UI API (when GraphQL insufficient)
|
|
22
|
+
const res = await sdk.fetch?.("/services/apexrest/my-resource");
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Always use optional chaining** (`sdk.graphql?.()`, `sdk.fetch?.()`) — these methods may be undefined in some surfaces.
|
|
26
|
+
|
|
27
|
+
## Supported APIs
|
|
28
|
+
|
|
29
|
+
**Only the following APIs are permitted.** Any endpoint not listed here must not be used.
|
|
30
|
+
|
|
31
|
+
| API | Method | Endpoints / Use Case |
|
|
32
|
+
|-----|--------|----------------------|
|
|
33
|
+
| GraphQL | `sdk.graphql` | All record queries and mutations via `uiapi { }` namespace |
|
|
34
|
+
| UI API REST | `sdk.fetch` | `/services/data/v{ver}/ui-api/records/{id}` — record metadata when GraphQL is insufficient |
|
|
35
|
+
| Apex REST | `sdk.fetch` | `/services/apexrest/{resource}` — custom server-side logic, aggregates, multi-step transactions |
|
|
36
|
+
| Connect REST | `sdk.fetch` | `/services/data/v{ver}/connect/file/upload/config` — file upload config |
|
|
37
|
+
| Einstein LLM | `sdk.fetch` | `/services/data/v{ver}/einstein/llm/prompt/generations` — AI text generation |
|
|
38
|
+
|
|
39
|
+
**Not supported:**
|
|
40
|
+
|
|
41
|
+
- **Enterprise REST query endpoint** (`/services/data/v*/query` with SOQL) — blocked at the proxy level. Use GraphQL for record reads; use Apex REST if server-side SOQL aggregates are required.
|
|
42
|
+
- **Aura-enabled Apex** (`@AuraEnabled`) — an LWC/Aura pattern with no invocation path from React webapps.
|
|
43
|
+
- **Chatter API** (`/chatter/users/me`) — use `uiapi { currentUser { ... } }` in a GraphQL query instead.
|
|
44
|
+
- **Any other Salesforce REST endpoint** not listed in the supported table above.
|
|
45
|
+
|
|
46
|
+
## Decision: GraphQL vs REST
|
|
47
|
+
|
|
48
|
+
| Need | Method | Example |
|
|
49
|
+
|------|--------|---------|
|
|
50
|
+
| Query/mutate records | `sdk.graphql` | Account, Contact, custom objects |
|
|
51
|
+
| Current user info | `sdk.graphql` | `uiapi { currentUser { Id Name { value } } }` |
|
|
52
|
+
| UI API record metadata | `sdk.fetch` | `/ui-api/records/{id}` |
|
|
53
|
+
| Connect REST | `sdk.fetch` | `/connect/file/upload/config` |
|
|
54
|
+
| Apex REST | `sdk.fetch` | `/services/apexrest/auth/login` |
|
|
55
|
+
| Einstein LLM | `sdk.fetch` | `/einstein/llm/prompt/generations` |
|
|
56
|
+
|
|
57
|
+
**GraphQL is preferred** for record operations. Use REST only when GraphQL doesn't cover the use case.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## GraphQL Workflow
|
|
62
|
+
|
|
63
|
+
### Step 1: Acquire Schema
|
|
64
|
+
|
|
65
|
+
The `schema.graphql` file (265K+ lines) is the source of truth. **Never open or parse it directly.**
|
|
66
|
+
|
|
67
|
+
1. Check if `schema.graphql` exists at the SFDX project root
|
|
68
|
+
2. If missing, run from the **webapp dir**: `npm run graphql:schema`
|
|
69
|
+
3. Custom objects appear only after metadata is deployed
|
|
70
|
+
|
|
71
|
+
### Step 2: Look Up Entity Schema
|
|
72
|
+
|
|
73
|
+
Map user intent to PascalCase names ("accounts" → `Account`), then **run the search script from the project root**:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# From project root — look up all relevant schema info for one or more entities
|
|
77
|
+
bash .a4drules/skills/using-salesforce-data/graphql-search.sh Account
|
|
78
|
+
|
|
79
|
+
# Multiple entities at once
|
|
80
|
+
bash .a4drules/skills/using-salesforce-data/graphql-search.sh Account Contact Opportunity
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The script outputs five sections per entity:
|
|
84
|
+
1. **Type definition** — all queryable fields and relationships
|
|
85
|
+
2. **Filter options** — available fields for `where:` conditions
|
|
86
|
+
3. **Sort options** — available fields for `orderBy:`
|
|
87
|
+
4. **Create input** — fields accepted by create mutations
|
|
88
|
+
5. **Update input** — fields accepted by update mutations
|
|
89
|
+
|
|
90
|
+
Use this output to determine exact field names before writing any query or mutation. **Maximum 2 script runs.** If the entity still can't be found, ask the user — the object may not be deployed.
|
|
91
|
+
|
|
92
|
+
### Step 3: Generate Query
|
|
93
|
+
|
|
94
|
+
Use the templates below. Every field name **must** be verified from the script output in Step 2.
|
|
95
|
+
|
|
96
|
+
#### Read Query Template
|
|
97
|
+
|
|
98
|
+
```graphql
|
|
99
|
+
query GetAccounts {
|
|
100
|
+
uiapi {
|
|
101
|
+
query {
|
|
102
|
+
Account(where: { Industry: { eq: "Technology" } }, first: 10) {
|
|
103
|
+
edges {
|
|
104
|
+
node {
|
|
105
|
+
Id
|
|
106
|
+
Name @optional { value }
|
|
107
|
+
Industry @optional { value }
|
|
108
|
+
# Parent relationship
|
|
109
|
+
Owner @optional { Name { value } }
|
|
110
|
+
# Child relationship
|
|
111
|
+
Contacts @optional {
|
|
112
|
+
edges { node { Name @optional { value } } }
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**FLS Resilience**: Apply `@optional` to all record fields. The server omits inaccessible fields instead of failing. Consuming code must use optional chaining:
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
const name = node.Name?.value ?? "";
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
#### Mutation Template
|
|
129
|
+
|
|
130
|
+
```graphql
|
|
131
|
+
mutation CreateAccount($input: AccountCreateInput!) {
|
|
132
|
+
uiapi {
|
|
133
|
+
AccountCreate(input: $input) {
|
|
134
|
+
Record { Id Name { value } }
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Mutation constraints:**
|
|
141
|
+
- Create: Include required fields, only `createable` fields, no child relationships
|
|
142
|
+
- Update: Include `Id`, only `updateable` fields
|
|
143
|
+
- Delete: Include `Id` only
|
|
144
|
+
|
|
145
|
+
#### Object Metadata & Picklist Values
|
|
146
|
+
|
|
147
|
+
Use `uiapi { objectInfos(...) }` to fetch field metadata or picklist values. Pass **either** `apiNames` or `objectInfoInputs` — never both in the same query.
|
|
148
|
+
|
|
149
|
+
**Object metadata** (field labels, data types, CRUD flags):
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
const GET_OBJECT_INFO = gql`
|
|
153
|
+
query GetObjectInfo($apiNames: [String!]!) {
|
|
154
|
+
uiapi {
|
|
155
|
+
objectInfos(apiNames: $apiNames) {
|
|
156
|
+
ApiName
|
|
157
|
+
label
|
|
158
|
+
labelPlural
|
|
159
|
+
fields {
|
|
160
|
+
ApiName
|
|
161
|
+
label
|
|
162
|
+
dataType
|
|
163
|
+
updateable
|
|
164
|
+
createable
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
`;
|
|
170
|
+
|
|
171
|
+
const sdk = await createDataSDK();
|
|
172
|
+
const response = await sdk.graphql?.(GET_OBJECT_INFO, { apiNames: ["Account"] });
|
|
173
|
+
const objectInfos = response?.data?.uiapi?.objectInfos ?? [];
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Picklist values** (use `objectInfoInputs` + `... on PicklistField` inline fragment):
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
const GET_PICKLIST_VALUES = gql`
|
|
180
|
+
query GetPicklistValues($objectInfoInputs: [ObjectInfoInput!]!) {
|
|
181
|
+
uiapi {
|
|
182
|
+
objectInfos(objectInfoInputs: $objectInfoInputs) {
|
|
183
|
+
ApiName
|
|
184
|
+
fields {
|
|
185
|
+
ApiName
|
|
186
|
+
... on PicklistField {
|
|
187
|
+
picklistValuesByRecordTypeIDs {
|
|
188
|
+
recordTypeID
|
|
189
|
+
picklistValues {
|
|
190
|
+
label
|
|
191
|
+
value
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
`;
|
|
200
|
+
|
|
201
|
+
const response = await sdk.graphql?.(GET_PICKLIST_VALUES, {
|
|
202
|
+
objectInfoInputs: [{ objectApiName: "Account" }],
|
|
203
|
+
});
|
|
204
|
+
const fields = response?.data?.uiapi?.objectInfos?.[0]?.fields ?? [];
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Step 4: Validate & Test
|
|
208
|
+
|
|
209
|
+
1. **Lint**: `npx eslint <file>` from webapp dir
|
|
210
|
+
2. **Test**: Ask user before testing. For mutations, request input values — never fabricate data.
|
|
211
|
+
|
|
212
|
+
**If ESLint reports a GraphQL error** (e.g. `Cannot query field`, `Unknown type`, `Unknown argument`), the field or type name is wrong. Re-run the schema search script to find the correct name — do not guess:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
# From project root — re-check the entity that caused the error
|
|
216
|
+
bash .a4drules/skills/using-salesforce-data/graphql-search.sh <EntityName>
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Then fix the query using the exact names from the script output.
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Webapp Integration (React)
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
import { createDataSDK, gql } from "@salesforce/sdk-data";
|
|
227
|
+
|
|
228
|
+
const GET_ACCOUNTS = gql`
|
|
229
|
+
query GetAccounts {
|
|
230
|
+
uiapi {
|
|
231
|
+
query {
|
|
232
|
+
Account(first: 10) {
|
|
233
|
+
edges {
|
|
234
|
+
node {
|
|
235
|
+
Id
|
|
236
|
+
Name @optional { value }
|
|
237
|
+
Industry @optional { value }
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
`;
|
|
245
|
+
|
|
246
|
+
const sdk = await createDataSDK();
|
|
247
|
+
const response = await sdk.graphql?.(GET_ACCOUNTS);
|
|
248
|
+
|
|
249
|
+
if (response?.errors?.length) {
|
|
250
|
+
throw new Error(response.errors.map(e => e.message).join("; "));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const accounts = response?.data?.uiapi?.query?.Account?.edges?.map(e => e.node) ?? [];
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## REST API Patterns
|
|
258
|
+
|
|
259
|
+
Use `sdk.fetch` when GraphQL is insufficient. See the [Supported APIs](#supported-apis) table for the full allowlist.
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
declare const __SF_API_VERSION__: string;
|
|
263
|
+
const API_VERSION = typeof __SF_API_VERSION__ !== "undefined" ? __SF_API_VERSION__ : "65.0";
|
|
264
|
+
|
|
265
|
+
// Connect — file upload config
|
|
266
|
+
const res = await sdk.fetch?.(`/services/data/v${API_VERSION}/connect/file/upload/config`);
|
|
267
|
+
|
|
268
|
+
// Apex REST (no version in path)
|
|
269
|
+
const res = await sdk.fetch?.("/services/apexrest/auth/login", {
|
|
270
|
+
method: "POST",
|
|
271
|
+
body: JSON.stringify({ email, password }),
|
|
272
|
+
headers: { "Content-Type": "application/json" },
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
// UI API — record with metadata (prefer GraphQL for simple reads)
|
|
276
|
+
const res = await sdk.fetch?.(`/services/data/v${API_VERSION}/ui-api/records/${recordId}`);
|
|
277
|
+
|
|
278
|
+
// Einstein LLM
|
|
279
|
+
const res = await sdk.fetch?.(`/services/data/v${API_VERSION}/einstein/llm/prompt/generations`, {
|
|
280
|
+
method: "POST",
|
|
281
|
+
body: JSON.stringify({ promptTextorId: prompt }),
|
|
282
|
+
});
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**Current user**: Do not use Chatter (`/chatter/users/me`). Use GraphQL instead:
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
const GET_CURRENT_USER = gql`
|
|
289
|
+
query CurrentUser {
|
|
290
|
+
uiapi { currentUser { Id Name { value } } }
|
|
291
|
+
}
|
|
292
|
+
`;
|
|
293
|
+
const response = await sdk.graphql?.(GET_CURRENT_USER);
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Directory Structure
|
|
299
|
+
|
|
300
|
+
```
|
|
301
|
+
<project-root>/ ← SFDX project root
|
|
302
|
+
├── schema.graphql ← grep target (lives here)
|
|
303
|
+
├── sfdx-project.json
|
|
304
|
+
└── force-app/main/default/webapplications/<app-name>/ ← webapp dir
|
|
305
|
+
├── package.json ← npm scripts
|
|
306
|
+
└── src/
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
| Command | Run From | Why |
|
|
310
|
+
|---------|----------|-----|
|
|
311
|
+
| `npm run graphql:schema` | webapp dir | Script in webapp's package.json |
|
|
312
|
+
| `npx eslint <file>` | webapp dir | Reads eslint.config.js |
|
|
313
|
+
| `bash .a4drules/skills/using-salesforce-data/graphql-search.sh <Entity>` | project root | Schema lookup |
|
|
314
|
+
| `sf api request rest` | project root | Needs sfdx-project.json |
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## Quick Reference
|
|
319
|
+
|
|
320
|
+
### Schema Lookup (from project root)
|
|
321
|
+
|
|
322
|
+
Run the search script to get all relevant schema info in one step:
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
bash .a4drules/skills/using-salesforce-data/graphql-search.sh <EntityName>
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
| Script Output Section | Used For |
|
|
329
|
+
|-----------------------|----------|
|
|
330
|
+
| Type definition | Field names, parent/child relationships |
|
|
331
|
+
| Filter options | `where:` conditions |
|
|
332
|
+
| Sort options | `orderBy:` |
|
|
333
|
+
| CreateRepresentation | Create mutation field list |
|
|
334
|
+
| UpdateRepresentation | Update mutation field list |
|
|
335
|
+
|
|
336
|
+
### Error Categories
|
|
337
|
+
|
|
338
|
+
| Error Contains | Resolution |
|
|
339
|
+
|----------------|------------|
|
|
340
|
+
| `Cannot query field` | Field name is wrong — run `graphql-search.sh <Entity>` and use the exact name from the Type definition section |
|
|
341
|
+
| `Unknown type` | Type name is wrong — run `graphql-search.sh <Entity>` to confirm the correct PascalCase entity name |
|
|
342
|
+
| `Unknown argument` | Argument name is wrong — run `graphql-search.sh <Entity>` and check Filter or OrderBy sections |
|
|
343
|
+
| `invalid syntax` | Fix syntax per error message |
|
|
344
|
+
| `validation error` | Field name is wrong — run `graphql-search.sh <Entity>` to verify |
|
|
345
|
+
| `VariableTypeMismatch` | Correct argument type from schema |
|
|
346
|
+
| `invalid cross reference id` | Entity deleted — ask for valid Id |
|
|
347
|
+
|
|
348
|
+
### Checklist
|
|
349
|
+
|
|
350
|
+
- [ ] All field names verified via search script (Step 2)
|
|
351
|
+
- [ ] `@optional` applied to record fields (reads)
|
|
352
|
+
- [ ] Optional chaining in consuming code
|
|
353
|
+
- [ ] Lint passes: `npx eslint <file>`
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# UI Platform Rule
|
|
2
|
+
|
|
3
|
+
**All new UI must be built as a Salesforce Web Application.**
|
|
4
|
+
|
|
5
|
+
When any task involves creating a new UI, frontend, page, dashboard, form, or user-facing feature:
|
|
6
|
+
|
|
7
|
+
1. Use `sf webapp generate` to scaffold the web app inside the SFDX project — do not use `create-react-app`, standalone Vite, or any other scaffold.
|
|
8
|
+
2. The app must live under `<sfdx-source>/webapplications/<AppName>/` as a WebApplication bundle.
|
|
9
|
+
3. Do not build new UIs as LWC components, Aura components, or Visualforce pages.
|
|
10
|
+
|
|
11
|
+
Invoke the `creating-webapp` skill (`.a4drules/skills/creating-webapp/`) for the full setup workflow.
|
|
12
|
+
|
|
13
|
+
## Data Access (MUST FOLLOW)
|
|
14
|
+
|
|
15
|
+
- **Never hardcode data in the app.** All data displayed in the UI must come from live Salesforce data fetching — no static arrays, mock objects, or placeholder values in production code.
|
|
16
|
+
- **Always invoke the `using-salesforce-data` skill** (`.a4drules/skills/using-salesforce-data/`) before writing any data access code. All implementation must be derived from that skill.
|
package/dist/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.112.4](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.112.3...v1.112.4) (2026-03-20)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* address PR [#332](https://github.com/salesforce-experience-platform-emu/webapps/issues/332) review feedback ([#336](https://github.com/salesforce-experience-platform-emu/webapps/issues/336)) ([5d499dd](https://github.com/salesforce-experience-platform-emu/webapps/commit/5d499dda12011bb201fba28d41eff1d168a2e937))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [1.112.3](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.112.2...v1.112.3) (2026-03-20)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **blitz:** make changes to rules and skills for blitz ([#332](https://github.com/salesforce-experience-platform-emu/webapps/issues/332)) ([f7baaa4](https://github.com/salesforce-experience-platform-emu/webapps/commit/f7baaa4d263b56ccea35b9e6bf57556edf22c530))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [1.112.2](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.112.1...v1.112.2) (2026-03-20)
|
|
7
29
|
|
|
8
30
|
**Note:** Version bump only for package @salesforce/webapp-template-base-sfdx-project-experimental
|
package/dist/force-app/main/default/webapplications/feature-react-global-search/package.json
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"graphql:schema": "node scripts/get-graphql-schema.mjs"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@salesforce/sdk-data": "^1.112.
|
|
19
|
-
"@salesforce/webapp-experimental": "^1.112.
|
|
18
|
+
"@salesforce/sdk-data": "^1.112.4",
|
|
19
|
+
"@salesforce/webapp-experimental": "^1.112.4",
|
|
20
20
|
"@tailwindcss/vite": "^4.1.17",
|
|
21
21
|
"class-variance-authority": "^0.7.1",
|
|
22
22
|
"clsx": "^2.1.1",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@graphql-eslint/eslint-plugin": "^4.1.0",
|
|
44
44
|
"@graphql-tools/utils": "^11.0.0",
|
|
45
45
|
"@playwright/test": "^1.49.0",
|
|
46
|
-
"@salesforce/vite-plugin-webapp-experimental": "^1.112.
|
|
46
|
+
"@salesforce/vite-plugin-webapp-experimental": "^1.112.4",
|
|
47
47
|
"@testing-library/jest-dom": "^6.6.3",
|
|
48
48
|
"@testing-library/react": "^16.1.0",
|
|
49
49
|
"@testing-library/user-event": "^14.5.2",
|
package/dist/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/webapp-template-base-sfdx-project-experimental",
|
|
3
|
-
"version": "1.112.
|
|
3
|
+
"version": "1.112.4",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@salesforce/webapp-template-base-sfdx-project-experimental",
|
|
9
|
-
"version": "1.112.
|
|
9
|
+
"version": "1.112.4",
|
|
10
10
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@lwc/eslint-plugin-lwc": "^3.3.0",
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/webapp-template-feature-react-global-search-experimental",
|
|
3
|
-
"version": "1.112.
|
|
3
|
+
"version": "1.112.4",
|
|
4
4
|
"description": "Global search feature for Salesforce objects with filtering and pagination",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"author": "",
|