### Post-Creation Project Setup
Source: https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/sfnext-cli
Commands to run after a storefront project has been created. This includes installing dependencies, building the project, and starting the development server.
```bash
cd my-storefront
pnpm install
pnpm build
pnpm dev
```
--------------------------------
### Example GET Request with URI Parameters
Source: https://developer.salesforce.com/docs/industries/cme/guide/comms-t-offers-item-api
This example demonstrates how to construct a GET request to the Offers Item API, including optional URI parameters for effective start time and expiration time. Ensure these parameters are in UTC date-time format and adhere to the specified constraints.
```HTTP
GET /services/apexrest/vlocity_cmt/v3/admin/catalogs/AS-Test-Catalog/offersitem?effectiveStartTime=2021-07-04T12:08:56&expirationTime=2021-08-04T12:08:56
```
--------------------------------
### Example GET Request for Promotion Item
Source: https://developer.salesforce.com/docs/industries/cme/guide/comms-t-retrieve-details-of-items-in-a-promotion
An example of a GET request to retrieve a specific promotion item, including placeholder IDs.
```nolang
GET /v2/epc/promotions/a3K3h0000006Aj3EAE/items/a3J3h000000I4KKEA0
```
--------------------------------
### Install CocoaPods Gem and Setup
Source: https://developer.salesforce.com/docs/ai/agentforce-mobile-sdk/guide/agentforce-mobile-sdk-ios-install
Installs the CocoaPods gem and initializes the local main repository. Run this if you don't have CocoaPods installed.
```ruby
sudo gem install cocoapods
pod setup
```
--------------------------------
### Install Dependencies and Run Dev Server
Source: https://developer.salesforce.com/docs/platform/lwr/guide/lwr-get-started
After creating your project, navigate into the project directory, install its dependencies, and start a live preview server.
```bash
cd StaticSite
npm install
npm run dev
```
--------------------------------
### Example Install IMPEX for services.xml
Source: https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/packaging
Shows the structure of an install services.xml file, including service credentials, profiles, and definitions. Use placeholder credentials for API keys and secrets.
```xml
https://api.example.com
YOUR_API_KEY
YOUR_API_SECRET
5000
true
10
1000
HTTP
true
```
--------------------------------
### Route Examples for Headless Pages
Source: https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/page-designer
Examples of route configurations for different page types in a headless setup.
```json
"route": "/"
```
```json
"route": "/about"
```
```json
"route": "/contact"
```
```json
"route": "/product/:productId"
```
```json
"route": "/category/:categoryId"
```
--------------------------------
### Example GET Request for Promotions
Source: https://developer.salesforce.com/docs/industries/cme/guide/comms-get-applied-or-available-promotions-for-cart
This example demonstrates how to make a GET request to retrieve promotions for a specific cart, including filtering and field selection.
```http
GET /services/apexrest/vlocity_cmt/v2/cpq/carts/80141000000bARD/promotions?filters=vlocity_cmt_Codec:Test1,Name:Promo1_Promo2&fields=Name,vlocity_cmtCodec,vlocity_cmtIsActive_c
```
--------------------------------
### Run Azure File Notification Installer
Source: https://developer.salesforce.com/docs/data/data-cloud-int/guide/c360-a-azure-udlo
Make the setup script executable and then run it with the configuration file. This script installs and configures the Azure file notification pipeline.
```bash
chmod +x setup_azure_file_notification.sh
./setup_azure_file_notification.sh input_parameters_azure.conf
```
--------------------------------
### Example Salesforce CLI Version Output
Source: https://developer.salesforce.com/docs/platform/lwc/guide/get-started-cli
This is an example output from the `sf plugins --core` command, showing the installed version of the Salesforce CLI.
```bash
@salesforce/cli 2.24.3 (core)
```
--------------------------------
### Subscribe RPC Example
Source: https://developer.salesforce.com/docs/platform/pub-sub-api/guide/qs-java-publish-subscribe
This example demonstrates how to initiate a subscription to a platform event topic. It logs connection details and subscription status. Ensure you have the necessary credentials and topic configured.
```text
2024-04-09 11:56:35,443 [main] java.lang.Class - Using grpcHost api.pubsub.salesforce.com and grpcPort 7443
2024-04-09 11:56:36,610 [main] utility.APISessionCredentials - Client Trace Id for current request:
161d4754-cd94-446e-8c41-77626805dd7c
2024-04-09 11:56:37,126 [main] java.lang.Class - Subscription started for topic:
/event/Order_Event__e.
2024-04-09 11:56:37,128 [main] utility.APISessionCredentials - Client Trace Id for current request:
aeecdf2c-9522-4d1d-a4ba-359f137cf53e
2024-04-09 11:56:42,140 [main] java.lang.Class - Subscription Active. Received a total of 0 events.
```
--------------------------------
### Example GET Request for Cart Products
Source: https://developer.salesforce.com/docs/industries/cme/guide/comms-get-list-of-products
Demonstrates how to make a GET request to retrieve products for a specific cart, including pagination.
```http
GET
/services/apexrest/vlocity_cmt/v2/cpq/carts/80141000000Cg8H/products?pagesize=5
```
--------------------------------
### Run Pub/Sub API Subscribe Example
Source: https://developer.salesforce.com/docs/platform/pub-sub-api/guide/qs-java-change-events
Execute the generic Pub/Sub API subscribe example from the command line. This command initiates the subscription to the configured change event channel.
```bash
./run.sh genericpubsub.Subscribe
```
--------------------------------
### Display Code Analyzer Installation Status
Source: https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/guide/setup
This is an example of the output when Code Analyzer is installed. It shows the plugin name and its version.
```bash
@salesforce/sfdx-scanner 4.3.0
```
--------------------------------
### Start Local Web Server
Source: https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/quick-start
Navigate to the project directory and run this command to start the local development server for previewing your storefront.
```bash
cd retail-react-app-demo
npm start
```
--------------------------------
### MCP Client Configuration Examples
Source: https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/guide/mcp
Examples of configuration properties for the MCP client, including results file path, selector syntax, and pagination settings.
```json
"resultsFile": "/tmp/results.json"
```
```json
"selector": "Security:pmd"
```
```json
"selector": "Critical"
```
```json
"selector": "(Security,Performance):eslint"
```
```json
"selector": "rule=MyRuleName"
```
```json
"selector": "file=src/app"
```
```json
"topN": 5
```
```json
"allowLargeResultSet": true
```
```json
"sortBy": "severity"
```
```json
"sortDirection": "desc"
```
--------------------------------
### Count Individuals by First Name
Source: https://developer.salesforce.com/docs/data/data-cloud-query-guide/guide/aggregate-query-results
Use COUNT to get the number of individuals whose first name starts with a specific pattern. This example queries the ssot__Individual__dlm object.
```sql
SELECT COUNT("ssot__Id__c") AS count1
FROM "ssot__Individual__dlm"
WHERE "ssot__FirstName__c" LIKE 'E%'
```
--------------------------------
### Display Detailed Command Help
Source: https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/guide/setup
To get comprehensive help for a specific command, including full descriptions and examples, append the --help flag to the command.
```bash
sf scanner run --help
```
--------------------------------
### Count Unified Individuals by First Name
Source: https://developer.salesforce.com/docs/data/data-cloud-query-guide/guide/aggregate-query-results
Use COUNT to get the number of unified individuals whose first name starts with a specific pattern. This example queries the UnifiedIndividual__dlm object.
```sql
SELECT COUNT("ssot__Id__c") AS count1
FROM "UnifiedIndividual__dlm"
WHERE "ssot__FirstName__c" LIKE 'E%'
```
--------------------------------
### Complete Apex Class with Continuation
Source: https://developer.salesforce.com/docs/platform/lwc/guide/apex-continuations-apex
A full example of an Apex class demonstrating the use of Continuation for a single long-running HTTP GET request, including setup, callout, and response processing.
```apex
public with sharing class SampleContinuationClass {
// Callout endpoint as a named credential URL
// or, as shown here, as the long-running service URL
private static final String LONG_RUNNING_SERVICE_URL =
'';
// Action method
@AuraEnabled(continuation=true cacheable=true)
public static Object startRequest() {
// Create continuation. Argument is timeout in seconds.
Continuation con = new Continuation(40);
// Set callback method
con.continuationMethod='processResponse';
// Set state
con.state='Hello, World!';
// Create callout request
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setEndpoint(LONG_RUNNING_SERVICE_URL);
// Add callout request to continuation
con.addHttpRequest(req);
// Return the continuation
return con;
}
// Callback method
@AuraEnabled(cacheable=true)
public static Object processResponse(List labels, Object state) {
// Get the response by using the unique label
HttpResponse response = Continuation.getResponse(labels[0]);
// Set the result variable
String result = response.getBody();
return result;
}
}
```
--------------------------------
### Build and Run Development Server
Source: https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/sfnext-customize
Builds the Storefront Next application for production and then starts the development server for local testing.
```bash
pnpm run build
pnpm run dev
```
--------------------------------
### Implement a Configuration Hook
Source: https://developer.salesforce.com/docs/platform/lwr/guide/lwr-routing-server
This example demonstrates a configuration hook that generates sidebar navigation and dynamic routes based on guide content. It updates global data and adds routes to the LWR configuration.
```javascript
import path from 'path';
import { DEFAULT_LWR_BOOTSTRAP_CONFIG } from '@lwrjs/config';
import { slugify } from '@lwrjs/shared-utils';
import type { HooksPlugin, NormalizedLwrGlobalConfig, NormalizedLwrRoute, GlobalData } from '@lwrjs/types';
const DEFAULT_MAIN_LAYOUT = 'main_layout.njk';
const CACHE_TTL = '30m';
interface GuideItem {
label: string;
content: string;
}
interface GuideSidebarItem {
label: string;
id: string;
url: string;
}
interface SiteGlobalData extends GlobalData {
site?: {
guide: GuideItem[];
sidebar: GuideSidebarItem[];
};
}
function generateGuideSidebar(guide: GuideItem[]): GuideSidebarItem[] {
return guide.map(({ label, content }) => {
return {
label,
id: `guide_${slugify(label)}`,
url: `/${content.replace('.md', '')}`,
};
});
}
function generateGuideRoutes(
guide: GuideItem[],
{ contentDir, layoutsDir }: NormalizedLwrGlobalConfig,
): NormalizedLwrRoute[] {
return guide.map(({ label, content }) => {
return {
id: `guide_${slugify(label)}`,
path: `/${content.replace('.md', '')}`,
contentTemplate: path.join(contentDir, content),
layoutTemplate: path.join(layoutsDir, DEFAULT_MAIN_LAYOUT),
cache: { ttl: CACHE_TTL },
bootstrap: DEFAULT_LWR_BOOTSTRAP_CONFIG,
};
});
}
// Export an Application Configuration hook
// Configured in lwr.config.json[hooks]
export default class MyAppHooks implements HooksPlugin {
initConfigs(lwrConfig: NormalizedLwrGlobalConfig, globalData: SiteGlobalData): void {
if (!globalData.site) {
throw 'Expected site global data to be defined';
}
// The guide is an ordered list of files we want to display
// Hardcoded here: src/data/site/guide.json
const guide = globalData.site.guide;
// Generate sidebar add it to the globalData object
// The data is accessed in src/layouts/partials/guide-sidebar.njk
globalData.site.sidebar = generateGuideSidebar(guide);
// Dynamically add a new route for each guide
// Note: other routes are statically declared in lwr.config.json[routes]
lwrConfig.routes.push(...generateGuideRoutes(guide, lwrConfig));
}
}
```
--------------------------------
### Example Experience Cloud SSO Initialization URL
Source: https://developer.salesforce.com/docs/platform/mobile-sdk/guide/communities-configure-community-auth
An example of a customized Single Sign-On Initialization URL for an Experience Cloud site, demonstrating the integration with a Facebook login provider.
```html
https://MYDOMAINNAME.my.salesforce.com/services/auth/sso/00Da0000000TPNEAA4/
FB_Community_Login?community= https://MYDOMAINNAME.my.site.com/fineapps
```
--------------------------------
### Example Request to Get Contracts
Source: https://developer.salesforce.com/docs/industries/cme/guide/comms-get-contracts-for-account
This example demonstrates the GET request to retrieve contracts for a specific account ID.
```http
GET
/services/apexrest/vlocity_cmt/v2/accounts/0011I000007lzDO/contracts
```
--------------------------------
### Example tasksList.json Structure
Source: https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/packaging
Defines the post-install configuration steps for the Business Manager setup wizard. Each task includes a number, name, description, a deep link to the relevant Business Manager page, and an initial status.
```json
[
{
"taskNumber": 1,
"name": "Enable Tax Service",
"description": "Navigate to Site Preferences and enable the tax calculation service",
"link": "/on/demandware.store/Sites-Site/default/ViewApplication-BM?..."
},
{
"taskNumber": 2,
"name": "Configure API Credentials",
"description": "Enter your account ID and license key in site preferences",
"link": "/on/demandware.store/Sites-Site/default/ViewApplication-BM?..."
}
]
```
--------------------------------
### Create a Storefront Project
Source: https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/sfnext-cli
Use the `create-storefront` command with `pnpm dlx` to initialize a new Storefront Next project when no local project exists.
```bash
pnpm dlx @salesforce/storefront-next-dev create-storefront
```
--------------------------------
### Get Basket Details for Anonymous User - Example
Source: https://developer.salesforce.com/docs/industries/cme/guide/comms-t-get-basket-details-api
Example of a GET request to retrieve basket details for an anonymous user.
```http
GET /services/apexrest/vlocity_cmt/v3/catalogs/Mobile/basket/bdbe113c6fd2d90835372d104f7a4a8b
```
--------------------------------
### Example RouteInstance
Source: https://developer.salesforce.com/docs/platform/lwr/references/csr-reference/routeinstance
An example of a RouteInstance object.
```APIDOC
## Example RouteInstance
```sfdocs-code {"lang":"javascript", "title": "Example RouteInstance", "src": "" }
{
id: '1',
pageReference: {
type: 'animal',
attributes: { pageName: 'animal' },
state: {},
},
},
```
```
--------------------------------
### Site Navbar JSON Example
Source: https://developer.salesforce.com/docs/platform/lwr/guide/lwr-compile-data
Shows an example of a JSON file containing site navigation data, which can be included as global context.
```json
// $rootDir/src/data/site/navbar.json
[
{
"id": "guide",
"name": "Guide",
"url": "/guide/introduction"
},
{
"id": "recipes",
"name": "Recipes",
"url": "/recipes"
}
]
```
--------------------------------
### Example GET Request for Assets
Source: https://developer.salesforce.com/docs/industries/cme/guide/comms-get-assets-for-account
Example of a GET request to retrieve assets for a specific account, including pagination and filtering parameters.
```HTTP
GET /services/apexrest/vlocity_cmt/v2/accounts/0011I000007lzDO/assets?pagesize=2&includes=noContractAssets&effectiveAssetsDateFilter=2019-04-05T07:00:00.000Z
```
--------------------------------
### Start Channel Connector App with Maven
Source: https://developer.salesforce.com/docs/service/einstein-bot-api/guide/connector-get-started
Use this command to start the Spring Boot application. Ensure your `application.properties` file is correctly configured.
```bash
mvn spring-boot:run
```
--------------------------------
### Example GET Request for Cart Attributes
Source: https://developer.salesforce.com/docs/industries/cme/guide/comms-get-filterable-attributes
This example shows a sample GET request to the resource URL for retrieving cart attributes.
```HTTP
GET
/services/apexrest/vlocity_cmt/v2/cpq/carts/80136000000siLM/attributes
```
--------------------------------
### Create App from Template (Basic Usage)
Source: https://developer.salesforce.com/docs/platform/mobile-sdk/guide/android-new-project
Use this command to create an app from a specified template repository URI. This is useful for starting projects with pre-defined structures.
```bash
forcedroid createwithtemplate --templaterepouri=AndroidNativeKotlinTemplate
```
--------------------------------
### Example GET Request for Cart Pricing
Source: https://developer.salesforce.com/docs/industries/cme/guide/comms-price-items-in-cart__query-
An example of a GET request to the cart pricing API, specifying `price=true` to run the pricing engine.
```nolang
GET
/services/apexrest/vlocity_cmt/v2/cpq/carts/80146000000iwCx/price?price=true
```
--------------------------------
### Initialize SDK (7.x) with Status Handling
Source: https://developer.salesforce.com/docs/marketing/mobile-unified-sdk/guide/troubleshooting-android
This example shows how to initialize the SDK in version 7.x and handle various initialization statuses, including degraded functionality due to location or messaging permission errors. It also logs success or failure.
```kotlin
MarketingCloudSdk.init(context, config) { status ->
when (status.status()) {
InitializationStatus.Status.COMPLETED_WITH_DEGRADED_FUNCTIONALITY -> {
if (status.locationsError()) {
//Handle Google Play Services issues.
if (GoogleApiAvailability.getInstance().isUserResolvableError(status.playServicesStatus())) {
// User will likely need to update GooglePlayServices through the Play Store.
// Call GoogleApiAvailability.getInstance().showErrorDialogFragment(...) from Activity.
}
} else if (status.messagingPermissionError()) {
// User disabled location permission.
// Re-request permission and if granted enable desired messaging type
}
}
InitializationStatus.Status.SUCCESS -> Log.v("MyApp", "MobilePush init was successful")
InitializationStatus.Status.FAILED -> Log.e(
"MyApp",
"MobilePush failed to initialize. Status: $status",
status.unrecoverableException()
)
}
}
```
--------------------------------
### Example GET Request for Cart Summary
Source: https://developer.salesforce.com/docs/industries/cme/guide/comms-get-cart-summary
This example shows the GET request format to retrieve a cart summary from the Communications CPQ API.
```http
GET
/services/apexrest/vlocity_cmt/v2/cpq/carts/80141000000Cg8H
```
--------------------------------
### Start LWR Server with Credentials
Source: https://developer.salesforce.com/docs/platform/lwr/guide/lwr-auth-middleware
Start your LWR application using yarn start and set the CLIENT_KEY and CLIENT_SECRET environment variables. These values should be obtained from your Salesforce Connected App.
```javascript
CLIENT_KEY=abc.123 CLIENT_SECRET=****** yarn start
```
--------------------------------
### Get Basket Details for Known User - Example
Source: https://developer.salesforce.com/docs/industries/cme/guide/comms-t-get-basket-details-api
Example of a GET request to retrieve basket details for a logged-in user, including account context.
```http
GET /services/apexrest/vlocity_cmt/v3/catalogs/TEST/basket/bdbe113c6fd2d90835372d104f7a4a8b?context={"accountId":"xxxxxxxxxxxxxx"}&isloggedin=true
```
--------------------------------
### Sample Response for GET List of All Product Offering Prices
Source: https://developer.salesforce.com/docs/industries/communications/guide/product-offering-price-use-cases
Example of a successful response when retrieving a list of all product offering prices.
```JSON
{
"PageInfo": "Page 1 of 8",
"PageSize": 5,
"Result": [
{
"priceType": "One-time",
"price": {
"value": 10.00000,
"unit": "USD"
},
"id": "ab5f8d7a-b852-cce1-fe27-9b2ea7742f6c",
"description": "sample description",
"name": "sample name",
"href": "/services/apexrest/vlocity_cmt/tmforum/productopenapi/v1/priceListEntry/a3C5e000000jCB6EAM",
"lastUpdate": "2023-08-31T19:17:36.000+0000",
"validFor": {
"startDateTime": "2023-07-31T18:30:00.000+0000"
},
"lifecycleStatus": "true"
},
{
"priceType": "One-time",
"price": {
"value": 100.00000,
"unit": "EUR"
},
"id": "680c0059-8a2b-77a2-b96e-afb57b5951bf",
"description": "sample description",
"name": "sample name",
"href": "/services/apexrest/vlocity_cmt/tmforum/productopenapi/v1/priceListEntry/a3C5e000000jCBBEA2",
"lastUpdate": "2023-08-31T19:21:34.000+0000",
"validFor": {
"startDateTime": "2022-08-31T18:30:00.000+0000"
},
"lifecycleStatus": "true"
},
{
"priceType": "One-time",
"price": {
"value": 1.00000,
"unit": "EUR"
},
"id": "72027007-33af-4272-342e-453de754bb6e",
"description": "sample description",
"name": "sample name",
"href": "/services/apexrest/vlocity_cmt/tmforum/productopenapi/v1/priceListEntry/a3C5e000000jCBGEA2",
"lastUpdate": "2023-08-31T19:23:33.000+0000",
"validFor": {
"startDateTime": "2019-09-03T18:30:00.000+0000"
},
"lifecycleStatus": "true"
}
]
}
```
--------------------------------
### Start Production Build Preview Server
Source: https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/sfnext-cli
Use this command to serve a production build locally. If no build exists, it automatically runs `pnpm build` first.
```bash
pnpm start
```
```bash
pnpm sfnext preview [options]
```
--------------------------------
### Example Request for Get Cart Promotions
Source: https://developer.salesforce.com/docs/industries/cme/guide/comms-get-cart-promotions
An example of a GET request to the cart promotions API, including parameters for query, sort order, and filters.
```HTTP
GET /services/apexrest/vlocity_cmt/v2/cpq/carts/8011I000000TUaK/promotions?query=iphone&sortBy=Id&filters=vlocity_cmt__Code__c:Root-Promo
```
--------------------------------
### Build and start LWR application
Source: https://developer.salesforce.com/docs/platform/lwr/guide/lwr-lwc
Run the build and start commands to compile your LWR application and launch a local preview. Check terminal output for the exact port if 3000 is in use.
```bash
npm run build
npm run start
```
--------------------------------
### Create App from Template (Full Usage)
Source: https://developer.salesforce.com/docs/platform/mobile-sdk/guide/android-new-project
This command provides detailed usage information for creating an app from a template repository. It outlines all required parameters such as template URI, app name, package name, organization, and output directory.
```bash
Usage:
forcedroid createWithTemplate
--templaterepouri= (e.g. https://github.com/forcedotcom/SalesforceMobileSDK-Templates/MobileSyncExplorerReactNative)]
--appname=
--packagename= (e.g. com.mycompany.myapp)
--organization= (Your company's/organization's name)
--outputdir=