@salesforce/mcp-provider-lwc-experts 0.1.0
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/LICENSE.txt +21 -0
- package/README.md +82 -0
- package/agents/lds/resources/lwc/guides/reference/reference-create-list-info.md +53 -0
- package/agents/lds/resources/lwc/guides/reference/reference-create-record.md +52 -0
- package/agents/lds/resources/lwc/guides/reference/reference-delete-list-info.md +56 -0
- package/agents/lds/resources/lwc/guides/reference/reference-delete-record.md +78 -0
- package/agents/lds/resources/lwc/guides/reference/reference-get-list-info-by-name.md +60 -0
- package/agents/lds/resources/lwc/guides/reference/reference-get-list-infos-by-name.md +55 -0
- package/agents/lds/resources/lwc/guides/reference/reference-get-list-infos-by-object-name.md +64 -0
- package/agents/lds/resources/lwc/guides/reference/reference-get-list-object-info.md +55 -0
- package/agents/lds/resources/lwc/guides/reference/reference-get-list-preferences.md +60 -0
- package/agents/lds/resources/lwc/guides/reference/reference-get-list-records-by-name.md +84 -0
- package/agents/lds/resources/lwc/guides/reference/reference-update-list-info.md +64 -0
- package/agents/lds/resources/lwc/guides/reference/reference-update-list-preferences.md +68 -0
- package/agents/lds/resources/lwc/guides/reference/reference-update-record.md +75 -0
- package/agents/lds/resources/lwc/guides/reference/wire-adapters/lds-wire-adapter-types.json +1330 -0
- package/agents/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-get-related-list-count.md +58 -0
- package/agents/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-get-related-list-info-batch.md +29 -0
- package/agents/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-get-related-list-info.md +36 -0
- package/agents/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-get-related-list-records-batch.md +48 -0
- package/agents/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-get-related-list-records.md +34 -0
- package/agents/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-get-related-lists-info.md +28 -0
- package/agents/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-object-info.md +51 -0
- package/agents/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-object-infos.md +54 -0
- package/agents/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-picklist-values-record.md +29 -0
- package/agents/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-picklist-values.md +78 -0
- package/agents/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-record.md +114 -0
- package/agents/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-records.md +142 -0
- package/index.bundle.d.ts +10 -0
- package/index.bundle.js +375 -0
- package/package.json +49 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# `getRelatedListCount`
|
|
2
|
+
|
|
3
|
+
Use this wire adapter to get the `RelatedList` record count.
|
|
4
|
+
|
|
5
|
+
## Syntax
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import { LightningElement, wire } from 'lwc';
|
|
9
|
+
import { getRelatedListCount } from 'lightning/uiRelatedListApi';
|
|
10
|
+
|
|
11
|
+
export default class LdsGetRelatedListCount extends LightningElement {
|
|
12
|
+
@wire(getRelatedListCount, {
|
|
13
|
+
parentRecordId: '001RM000003UNu6YAG',
|
|
14
|
+
relatedListId: 'Contacts',
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Parameters
|
|
20
|
+
|
|
21
|
+
- **`parentRecordId`** (String, Required) – The ID of the parent record, such as an Account ID.
|
|
22
|
+
- **`relatedListId`** (String, Required) – The API name of a related list object, such as Contacts, Opportunities, or Cases.
|
|
23
|
+
- **`maxCount`** (Number) – The maximum number of records to return. Default is 20.
|
|
24
|
+
|
|
25
|
+
## Returns
|
|
26
|
+
|
|
27
|
+
- **`data`** – Related List Record Count.
|
|
28
|
+
- **`error`** – FetchResponse.
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
This example fetches the record count for a related list.
|
|
33
|
+
|
|
34
|
+
### **JavaScript**
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
import { LightningElement, wire } from 'lwc';
|
|
38
|
+
import { getRelatedListCount } from 'lightning/uiRelatedListApi';
|
|
39
|
+
|
|
40
|
+
export default class WireGetRelatedListCount extends LightningElement {
|
|
41
|
+
error;
|
|
42
|
+
responseData;
|
|
43
|
+
|
|
44
|
+
@wire(getRelatedListCount, {
|
|
45
|
+
parentRecordId: '001RM000003UNu6YAG',
|
|
46
|
+
relatedListId: 'Contacts',
|
|
47
|
+
})
|
|
48
|
+
listInfo({ error, data }) {
|
|
49
|
+
if (data) {
|
|
50
|
+
this.responseData = data;
|
|
51
|
+
this.error = undefined;
|
|
52
|
+
} else if (error) {
|
|
53
|
+
this.error = error;
|
|
54
|
+
this.responseData = undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# `getRelatedListInfoBatch`
|
|
2
|
+
|
|
3
|
+
Use this wire adapter to get metadata for a batch of `RelatedLists`.
|
|
4
|
+
|
|
5
|
+
## Syntax
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import { LightningElement, wire } from 'lwc';
|
|
9
|
+
import { getRelatedListInfoBatch } from 'lightning/uiRelatedListApi';
|
|
10
|
+
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
|
|
11
|
+
|
|
12
|
+
export default class LdsGetRelatedListInfoBatch extends LightningElement {
|
|
13
|
+
@wire(getRelatedListInfoBatch, {
|
|
14
|
+
parentObjectApiName: ACCOUNT_OBJECT.objectApiName,
|
|
15
|
+
relatedListNames: ['Contacts', 'Opportunities'],
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Parameters
|
|
21
|
+
|
|
22
|
+
- **`parentObjectApiName`** (String, Required) – API name of a parent object, such as `Account`.
|
|
23
|
+
- **`relatedListNames`** (String[], Required) – Array of related list API names, such as `Contacts`, `Opportunities`, or `Cases`. In the wire adapter code, `relatedListNames` maps to `relatedListIds` in the User Interface API resource.
|
|
24
|
+
- **`recordTypeId`** (String) – ID of the parent record type. If not provided, the default record type is used.
|
|
25
|
+
|
|
26
|
+
## Returns
|
|
27
|
+
|
|
28
|
+
- **`data`** – Simplified Batch Results.
|
|
29
|
+
- **`error`** – FetchResponse.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# `getRelatedListInfo`
|
|
2
|
+
|
|
3
|
+
Use this wire adapter to get metadata for `RelatedList`.
|
|
4
|
+
|
|
5
|
+
## Syntax
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import { LightningElement, wire } from 'lwc';
|
|
9
|
+
import { getRelatedListInfo } from 'lightning/uiRelatedListApi';
|
|
10
|
+
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
|
|
11
|
+
|
|
12
|
+
export default class LdsGetRelatedListInfo extends LightningElement {
|
|
13
|
+
@wire(getRelatedListInfo, {
|
|
14
|
+
parentObjectApiName: ACCOUNT_OBJECT.objectApiName,
|
|
15
|
+
relatedListId: 'Contacts',
|
|
16
|
+
recordTypeId: '012000000000000AAA', // optional
|
|
17
|
+
fields: ['Contact.Name', 'Contact.Id'], // optional
|
|
18
|
+
optionalFields: ['Contact.OptionalField'], // optional
|
|
19
|
+
restrictColumnsToLayout: false // optional
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Parameters
|
|
25
|
+
|
|
26
|
+
- **`parentObjectApiName`** (String, Required) – API name of a parent object, such as `Account`.
|
|
27
|
+
- **`relatedListId`** (String, Required) – API name of a related list object, such as `Contacts`, `Opportunities`, or `Cases`.
|
|
28
|
+
- **`recordTypeId`** (String) – ID of the parent record type. If not provided, the default record type is used.
|
|
29
|
+
- **`fields`** (String[]) – API names of related list fields to query. If a field is inaccessible, an error is returned.
|
|
30
|
+
- **`optionalFields`** (String[]) – Additional fields to query. Inaccessible fields are ignored but do not cause an error.
|
|
31
|
+
- **`restrictColumnsToLayout`** (Boolean) – If `true`, retrieves only list columns in the page layout; if `false`, retrieves all columns. Default is `true`.
|
|
32
|
+
|
|
33
|
+
## Returns
|
|
34
|
+
|
|
35
|
+
- **`data`** – Related List Info.
|
|
36
|
+
- **`error`** – FetchResponse.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# `getRelatedListRecordsBatch`
|
|
2
|
+
|
|
3
|
+
Use this wire adapter to get records for a batch of `RelatedLists`.
|
|
4
|
+
|
|
5
|
+
## Syntax
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import { LightningElement, wire } from 'lwc';
|
|
9
|
+
import { getRelatedListRecordsBatch } from 'lightning/uiRelatedListApi';
|
|
10
|
+
|
|
11
|
+
export default class LdsGetRelatedListRecordsBatch extends LightningElement {
|
|
12
|
+
@wire(getRelatedListRecordsBatch, {
|
|
13
|
+
parentRecordId: '001RM000003UNu6YAG',
|
|
14
|
+
relatedListParameters: [
|
|
15
|
+
{
|
|
16
|
+
relatedListId: 'Contacts',
|
|
17
|
+
fields: ['Contact.Name', 'Contact.Id'],
|
|
18
|
+
sortBy: ['Contact.Name']
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
relatedListId: 'Opportunities',
|
|
22
|
+
fields: ['Opportunity.Name', 'Opportunity.Amount'],
|
|
23
|
+
sortBy: ['Opportunity.Amount'],
|
|
24
|
+
where: "{ and: [{ Name: { like: \"ACME%\" }}] }"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Parameters
|
|
32
|
+
|
|
33
|
+
- **`parentRecordId`** (String, Required) – ID of the parent record, such as an Account ID.
|
|
34
|
+
- **`relatedListParameters`** (Object[], Required) – Array of related list parameter collections.
|
|
35
|
+
|
|
36
|
+
### **`relatedListParameters` Properties**
|
|
37
|
+
|
|
38
|
+
- **`relatedListId`** (String, Required) – API name of a related list object, such as `Contacts`, `Opportunities`, or `Cases`.
|
|
39
|
+
- **`fields`** (String[]) – API names of the related list’s column fields.
|
|
40
|
+
- **`optionalFields`** (String[]) – Additional fields in the related list.
|
|
41
|
+
- **`pageSize`** (Number) – Number of list records to return per page.
|
|
42
|
+
- **`sortBy`** (String[]) – Field API name(s) to sort by. Accepts one value per request.
|
|
43
|
+
- **`where`** (String) – Filter for related list records in GraphQL syntax.
|
|
44
|
+
|
|
45
|
+
## Returns
|
|
46
|
+
|
|
47
|
+
- **`data`** – Simplified Batch Results.
|
|
48
|
+
- **`error`** – FetchResponse.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# `getRelatedListRecords`
|
|
2
|
+
|
|
3
|
+
Use this wire adapter to get `RelatedList` records. Related lists display details and links to records associated with a specific record, such as contacts, cases, notes, or files related to an account.
|
|
4
|
+
|
|
5
|
+
## Syntax
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import { LightningElement, wire } from 'lwc';
|
|
9
|
+
import { getRelatedListRecords } from 'lightning/uiRelatedListApi';
|
|
10
|
+
|
|
11
|
+
export default class LdsGetRelatedListRecords extends LightningElement {
|
|
12
|
+
@wire(getRelatedListRecords, {
|
|
13
|
+
parentRecordId: '001RM000003UNu6YAG',
|
|
14
|
+
relatedListId: 'Contacts',
|
|
15
|
+
fields: ['Contact.Name','Contact.Id'],
|
|
16
|
+
sortBy: ['Contact.Name']
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Parameters
|
|
22
|
+
|
|
23
|
+
- **`parentRecordId`** (String, Required) – ID of the parent record, such as an Account ID.
|
|
24
|
+
- **`relatedListId`** (String, Required) – API name of a related list or child relationship (e.g., `Contacts`, `Opportunities`, `Cases`). For custom objects, use `Custom_Objects__r`.
|
|
25
|
+
- **`fields`** (String[]) – API names of the related list’s column fields. For standard fields on custom objects, use `Custom_Object__c.FieldName`; for custom fields, use `Custom_Object__c.FieldName__c`.
|
|
26
|
+
- **`optionalFields`** (String[]) – Additional fields in the related list.
|
|
27
|
+
- **`pageSize`** (Number) – Number of records per page (default: 50, range: 1-1999).
|
|
28
|
+
- **`sortBy`** (String[]) – API name of the field to sort by. Accepts one value per request.
|
|
29
|
+
- **`where`** (String) – Filter for related list records. Semi-joins and anti-joins are not supported.
|
|
30
|
+
|
|
31
|
+
## Returns
|
|
32
|
+
|
|
33
|
+
- **`data`** – Related List Record Collection.
|
|
34
|
+
- **`error`** – FetchResponse.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# `getRelatedListsInfo`
|
|
2
|
+
|
|
3
|
+
Use this wire adapter to get metadata for `RelatedLists` in an object’s default layout.
|
|
4
|
+
|
|
5
|
+
## Syntax
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import { LightningElement, wire } from 'lwc';
|
|
9
|
+
import { getRelatedListsInfo } from 'lightning/uiRelatedListApi';
|
|
10
|
+
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
|
|
11
|
+
|
|
12
|
+
export default class LdsGetRelatedListsInfo extends LightningElement {
|
|
13
|
+
@wire(getRelatedListsInfo, {
|
|
14
|
+
parentObjectApiName: ACCOUNT_OBJECT.objectApiName,
|
|
15
|
+
recordTypeId: '012000000000000AAA' // optional
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Parameters
|
|
21
|
+
|
|
22
|
+
- **`parentObjectApiName`** (String, Required) – API name of a parent object, such as `Account`.
|
|
23
|
+
- **`recordTypeId`** (String) – ID of the parent record type.
|
|
24
|
+
|
|
25
|
+
## Returns
|
|
26
|
+
|
|
27
|
+
- **`data`** – Related List Summary Collection.
|
|
28
|
+
- **`error`** – FetchResponse.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# `getObjectInfo`
|
|
2
|
+
|
|
3
|
+
Use this wire adapter to get metadata about a specific object, including its fields, child relationships, record types, and theme.
|
|
4
|
+
|
|
5
|
+
## Syntax
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import { LightningElement, wire } from 'lwc';
|
|
9
|
+
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
|
|
10
|
+
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
|
|
11
|
+
|
|
12
|
+
export default class Example extends LightningElement {
|
|
13
|
+
@wire(getObjectInfo, { objectApiName: ACCOUNT_OBJECT })
|
|
14
|
+
propertyOrFunction;
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Parameters
|
|
19
|
+
|
|
20
|
+
- **`objectApiName`** (String, Required) – API name of a supported object.
|
|
21
|
+
|
|
22
|
+
## Returns
|
|
23
|
+
|
|
24
|
+
- **`data`** – Object Info.
|
|
25
|
+
- **`error`** – FetchResponse.
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
Use `getObjectInfo` for a single object. For multiple objects, use `getObjectInfos`.
|
|
30
|
+
|
|
31
|
+
This example retrieves record type IDs and finds the ID for the record type named "Special Account":
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import { LightningElement, api, wire, track } from 'lwc';
|
|
35
|
+
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
|
|
36
|
+
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
|
|
37
|
+
|
|
38
|
+
export default class RecordFormWithRecordType extends LightningElement {
|
|
39
|
+
@api recordId;
|
|
40
|
+
@api objectApiName;
|
|
41
|
+
@track objectInfo;
|
|
42
|
+
|
|
43
|
+
@wire(getObjectInfo, { objectApiName: ACCOUNT_OBJECT })
|
|
44
|
+
objectInfo;
|
|
45
|
+
|
|
46
|
+
get recordTypeId() {
|
|
47
|
+
const rtis = this.objectInfo.data.recordTypeInfos;
|
|
48
|
+
return Object.keys(rtis).find((rti) => rtis[rti].name === 'Special Account');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# `getObjectInfos`
|
|
2
|
+
|
|
3
|
+
Use this wire adapter to get metadata for multiple objects, including fields, child relationships, record types, and themes.
|
|
4
|
+
|
|
5
|
+
## Syntax
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import { LightningElement, wire } from 'lwc';
|
|
9
|
+
import { getObjectInfos } from 'lightning/uiObjectInfoApi';
|
|
10
|
+
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
|
|
11
|
+
import OPPORTUNITY_OBJECT from '@salesforce/schema/Opportunity';
|
|
12
|
+
|
|
13
|
+
export default class GetObjectInfosExample extends LightningElement {
|
|
14
|
+
@wire(getObjectInfos, { objectApiNames: [ACCOUNT_OBJECT, OPPORTUNITY_OBJECT] })
|
|
15
|
+
propertyOrFunction;
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Parameters
|
|
20
|
+
|
|
21
|
+
- **`objectApiNames`** (String[], Required) – API names of supported objects.
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
- **`data`** – Contains a `results` object with Object Info metadata and status codes.
|
|
26
|
+
- **`error`** – FetchResponse.
|
|
27
|
+
|
|
28
|
+
### Response Structure
|
|
29
|
+
|
|
30
|
+
The metadata for each requested object is returned in `data.results` in the same order they were requested. If an object has an error, the error code and message are included in `data.results[].result`. The `error` object is returned only if the server call fails.
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"results": [
|
|
35
|
+
{
|
|
36
|
+
"result": ObjectInfo1,
|
|
37
|
+
"statusCode": 200
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"result": ObjectInfo2,
|
|
41
|
+
"statusCode": 200
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"result": [
|
|
45
|
+
{
|
|
46
|
+
"errorCode": "FORBIDDEN",
|
|
47
|
+
"message": "You don't have access to this record. Ask your administrator for help or to request access."
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"statusCode": 403
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# `getPicklistValuesByRecordType`
|
|
2
|
+
|
|
3
|
+
Use this wire adapter to retrieve values for all picklists of a specified record type.
|
|
4
|
+
|
|
5
|
+
## Syntax
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import { LightningElement, wire } from 'lwc';
|
|
9
|
+
import { getPicklistValuesByRecordType } from 'lightning/uiObjectInfoApi';
|
|
10
|
+
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
|
|
11
|
+
|
|
12
|
+
export default class Example extends LightningElement {
|
|
13
|
+
@wire(getPicklistValuesByRecordType, {
|
|
14
|
+
objectApiName: ACCOUNT_OBJECT,
|
|
15
|
+
recordTypeId: '012000000000000AAA',
|
|
16
|
+
})
|
|
17
|
+
propertyOrFunction;
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Parameters
|
|
22
|
+
|
|
23
|
+
- **`objectApiName`** (String, Required) – API name of a supported object.
|
|
24
|
+
- **`recordTypeId`** (String, Required) – ID of the record type. Use the Object Info `defaultRecordTypeId` property from `getObjectInfo`.
|
|
25
|
+
|
|
26
|
+
## Returns
|
|
27
|
+
|
|
28
|
+
- **`data`** – Picklist Values Collection.
|
|
29
|
+
- **`error`** – FetchResponse.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# `getPicklistValues`
|
|
2
|
+
|
|
3
|
+
Use this wire adapter to retrieve picklist values for a specified field.
|
|
4
|
+
|
|
5
|
+
## Syntax
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import { LightningElement, wire } from 'lwc';
|
|
9
|
+
import { getPicklistValues } from 'lightning/uiObjectInfoApi';
|
|
10
|
+
import INDUSTRY_FIELD from '@salesforce/schema/Account.Industry';
|
|
11
|
+
|
|
12
|
+
export default class Example extends LightningElement {
|
|
13
|
+
@wire(getPicklistValues, { recordTypeId: '012000000000000AAA', fieldApiName: INDUSTRY_FIELD })
|
|
14
|
+
propertyOrFunction;
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Parameters
|
|
19
|
+
|
|
20
|
+
- **`recordTypeId`** (String, Required) – ID of the record type. Use the Object Info `defaultRecordTypeId` property from `getObjectInfo`. If no default record type exists, the master record type is `012000000000000AAA`.
|
|
21
|
+
- **`fieldApiName`** (String, Required) – API name of the picklist field on a supported object.
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
- **`data`** – Picklist Values.
|
|
26
|
+
- **`error`** – FetchResponse.
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
Picklist values are scoped to a record type. For dependent picklists, `getPicklistValues` returns data for controlling fields and their mappings.
|
|
31
|
+
|
|
32
|
+
Both `recordTypeId` and `fieldApiName` are required. Use `getObjectInfo` to retrieve `defaultRecordTypeId` and pass it reactively to `getPicklistValues`.
|
|
33
|
+
|
|
34
|
+
This example retrieves the Rating field picklist values (`Hot`, `Warm`, `Cold`) from the Account object:
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
import { LightningElement, wire } from 'lwc';
|
|
38
|
+
import { getObjectInfo, getPicklistValues } from 'lightning/uiObjectInfoApi';
|
|
39
|
+
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
|
|
40
|
+
import RATING_FIELD from '@salesforce/schema/Account.Rating';
|
|
41
|
+
|
|
42
|
+
export default class WireGetRatingPicklist extends LightningElement {
|
|
43
|
+
accountRecordTypeId;
|
|
44
|
+
ratings;
|
|
45
|
+
|
|
46
|
+
@wire(getObjectInfo, { objectApiName: ACCOUNT_OBJECT })
|
|
47
|
+
results({ error, data }) {
|
|
48
|
+
if (data) {
|
|
49
|
+
this.accountRecordTypeId = data.defaultRecordTypeId;
|
|
50
|
+
this.error = undefined;
|
|
51
|
+
} else {
|
|
52
|
+
this.error = error;
|
|
53
|
+
this.accountRecordTypeId = undefined;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@wire(getPicklistValues, { recordTypeId: '$accountRecordTypeId', fieldApiName: RATING_FIELD })
|
|
58
|
+
picklistResults({ error, data }) {
|
|
59
|
+
if (data) {
|
|
60
|
+
this.ratings = data.values;
|
|
61
|
+
this.error = undefined;
|
|
62
|
+
} else {
|
|
63
|
+
this.error = error;
|
|
64
|
+
this.ratings = undefined;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Example Response
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
[
|
|
74
|
+
{ "attributes": null, "label": "Hot", "validFor": [], "value": "Hot" },
|
|
75
|
+
{ "attributes": null, "label": "Warm", "validFor": [], "value": "Warm" },
|
|
76
|
+
{ "attributes": null, "label": "Cold", "validFor": [], "value": "Cold" }
|
|
77
|
+
]
|
|
78
|
+
```
|
package/agents/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-record.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# `getRecord`
|
|
2
|
+
|
|
3
|
+
Use this wire adapter to retrieve a record’s data.
|
|
4
|
+
|
|
5
|
+
## Syntax
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import { LightningElement, wire } from 'lwc';
|
|
9
|
+
import { getRecord } from 'lightning/uiRecordApi';
|
|
10
|
+
|
|
11
|
+
@wire(getRecord, { recordId: string, fields: string|string[], optionalFields?: string|string[] })
|
|
12
|
+
propertyOrFunction;
|
|
13
|
+
|
|
14
|
+
@wire(getRecord, { recordId: string, layoutTypes: string|string[],
|
|
15
|
+
modes?: string|string[], optionalFields?: string|string[] })
|
|
16
|
+
propertyOrFunction;
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Parameters
|
|
20
|
+
|
|
21
|
+
- **`recordId`** (String, Required) – ID of a record from a supported object.
|
|
22
|
+
- **`fields`** (String[]) – Either `fields` or `layoutTypes` is required. A field or an array of fields to return. If a field is inaccessible, an error is returned. Use `optionalFields` if unsure about access.
|
|
23
|
+
- **`layoutTypes`** (String[]) – Either `fields` or `layoutTypes` is required. Specifies the fields to return. Options:
|
|
24
|
+
- **`Compact`** – Retrieves a record’s key fields.
|
|
25
|
+
- **`Full`** – Retrieves a full layout.
|
|
26
|
+
- **`modes`** (String[]) – Optional if `layoutTypes` is specified. Determines which fields to get from a layout. Options:
|
|
27
|
+
- **`Create`** – For UI that lets a user create a record.
|
|
28
|
+
- **`Edit`** – For UI that lets a user edit a record.
|
|
29
|
+
- **`View`** – (Default) For UI that displays a record.
|
|
30
|
+
- **`optionalFields`** (String[]) – Optional fields. If accessible, they’re included; if not, they are ignored without error.
|
|
31
|
+
|
|
32
|
+
## Returns
|
|
33
|
+
|
|
34
|
+
- **`data`** – Record response.
|
|
35
|
+
- **`error`** – FetchResponse.
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
This example retrieves a record and its field values:
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
import { LightningElement, wire } from 'lwc';
|
|
43
|
+
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
|
|
44
|
+
import NAME_FIELD from '@salesforce/schema/Account.Name';
|
|
45
|
+
import OWNER_NAME_FIELD from '@salesforce/schema/Account.Owner.Name';
|
|
46
|
+
import PHONE_FIELD from '@salesforce/schema/Account.Phone';
|
|
47
|
+
import INDUSTRY_FIELD from '@salesforce/schema/Account.Industry';
|
|
48
|
+
|
|
49
|
+
export default class Example extends LightningElement {
|
|
50
|
+
@wire(getRecord, {
|
|
51
|
+
recordId: '001456789012345678',
|
|
52
|
+
fields: [NAME_FIELD, INDUSTRY_FIELD],
|
|
53
|
+
optionalFields: [PHONE_FIELD, OWNER_NAME_FIELD],
|
|
54
|
+
})
|
|
55
|
+
account;
|
|
56
|
+
|
|
57
|
+
get name() {
|
|
58
|
+
return getFieldValue(this.account.data, NAME_FIELD);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get phone() {
|
|
62
|
+
return getFieldValue(this.account.data, PHONE_FIELD);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
get industry() {
|
|
66
|
+
return getFieldValue(this.account.data, INDUSTRY_FIELD);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
get owner() {
|
|
70
|
+
return getFieldValue(this.account.data, OWNER_NAME_FIELD);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Error Handling
|
|
76
|
+
|
|
77
|
+
Use a Promise with `then()` and `catch()` blocks. To display errors, use toasts from `lightning/platformShowToastEvent`.
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
import { LightningElement, api, wire } from 'lwc';
|
|
81
|
+
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
|
82
|
+
import { getRecord } from 'lightning/uiRecordApi';
|
|
83
|
+
|
|
84
|
+
const FIELDS = ['Contact.Name', 'Contact.Phone'];
|
|
85
|
+
|
|
86
|
+
export default class LoadContact extends LightningElement {
|
|
87
|
+
@api recordId;
|
|
88
|
+
contact;
|
|
89
|
+
name;
|
|
90
|
+
phone;
|
|
91
|
+
@wire(getRecord, { recordId: '$recordId', fields: FIELDS })
|
|
92
|
+
wiredRecord({ error, data }) {
|
|
93
|
+
if (error) {
|
|
94
|
+
let message = 'Unknown error';
|
|
95
|
+
if (Array.isArray(error.body)) {
|
|
96
|
+
message = error.body.map((e) => e.message).join(', ');
|
|
97
|
+
} else if (typeof error.body.message === 'string') {
|
|
98
|
+
message = error.body.message;
|
|
99
|
+
}
|
|
100
|
+
this.dispatchEvent(
|
|
101
|
+
new ShowToastEvent({
|
|
102
|
+
title: 'Error loading contact',
|
|
103
|
+
message,
|
|
104
|
+
variant: 'error',
|
|
105
|
+
}),
|
|
106
|
+
);
|
|
107
|
+
} else if (data) {
|
|
108
|
+
this.contact = data;
|
|
109
|
+
this.name = this.contact.fields.Name.value;
|
|
110
|
+
this.phone = this.contact.fields.Phone.value;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|