Introducing the @salesforce/schema!


@salesforce/schema allows you to easily import references to Salesforce objects and fields, making your development.

With @salesforce/schema, you can import the following:

1. Object references:

   - Use import objectName from "@salesforce/schema/bjectReference" to import a reference to a Salesforce object.
   
   - If the object is part of a managed package, include the namespace in the reference using import objectName from "@salesforce/schema/namespace__objectReference".


2. Field references:

   - Use import fieldName from "@salesforce/schema/object.fieldReference" to import a reference to a specific field within a Salesforce object.
 
   - You can specify up to 5 levels of spanning fields, allowing you to access nested fields easily.

Here's an example to illustrate the syntax:

import POSITION_OBJECT from "@salesforce/schema/Position__c";

import POSITION_OBJECT from "@salesforce/schema/ns__Position__c";

import NAME_FIELD from "@salesforce/schema/Account.Name";

import SPANNING_FIELD from "@salesforce/schema/Account.Owner.Name";

In the above example:

- POSITION_OBJECT is imported from the Salesforce object "Position__c" or "ns__Position__c".

- NAME_FIELD is imported from the "Name" field of the "Account" object.

- SPANNING_FIELD is imported from the "Name" field of the "Owner" object within the "Account" object.

Additionally, if you're working with objects or fields from a managed package, remember to include the namespace value.

0 Comments