Code Vision puts a grey line of links above your SFCC code. Above a controller route you can open or copy its storefront URL, list the places that call it and jump to the cartridges that extend it. Above a hook or step type function a lens opens its declaration, and gutter icons link the files of a custom API
api.json, the schema and the script, and the lens in site.xml edits the cartridge pathLens groups
Each kind of lens is a group in Settings › Editor › Inlay Hints › Code vision. Uncheck a group to hide its lenses
| Group | Lenses |
|---|---|
| SFCC routes | Open Endpoint, Copy Endpoint URL, usages and SFRA targets of controller routes and pipeline start nodes, see Routes |
| SFCC hooks | The hooks.json declaration of each hook function, see Hooks |
| SFCC step types | The steptypes.json declaration of each step type function, and the jobs that run each step type, see Step types |
| SFCC cartridge path | Edit cartridge path above a site's or Business Manager's cartridge path, see Cartridge path |
| Digital Script | The scripts and templates that use a function through importScript, such as used in 2 scripts, 1 template via importScript, see Navigation and usages |
| SFCC Forms | Usages above each element of form XML, see Forms |
| SFCC Custom Attributes | Usages above each attribute definition of metadata XML, see Custom Attributes |
| SFCC Site Archives | Usages at the end of each ID of site archive XML that code names, such as a service or a category, see Usages and links in the XML |
| SFCC Page Designer | The library pages and components of each Page Designer type, see Page Designer types |
The lenses of templates, such as the usage count and Rendered by, are in the ISML group, see ISML navigation
Which files have lenses
Lenses show in the local files of your linked cartridges, see Cartridges & Modules
- Scripts (
.js,.dsand.ts) - Pipeline XML under
cartridge/pipelines - Route lenses in a script need the file under
cartridge/controllers - Site archive XML anywhere in the project, for SFCC Site Archives
Files in a node_modules, test, __test__ or __tests__ folder, under cartridge/client or cartridge/static, in a folder whose name starts with a dot, and files with .test. in their name have no lenses. Every lens needs a valid license or trial
Routes
Every route a controller declares gets these lenses
| Lens | Click |
|---|---|
| Open Endpoint | Opens the route on the active connection in your browser |
| Copy Endpoint URL | Copies the same URL |
| Usages, such as 5 usages | Lists the places that call the route, see Usages |
| SFRA targets, such as prepend (1), append (2), replace (1) | Lists the cartridges that extend the route, see SFRA extensions |
The usage lens shows 0 usages too. An SFRA target lens shows only when another declaration of the route uses that method
Open Endpoint and Copy Endpoint URL
Both build the storefront URL of the route from the active connection and the site selected in the Site Scope widget, for example https://zzrf-001.dx.commercecloud.salesforce.com/on/demandware.store/Sites-RefArch-Site/default/Cart-Show. When the URL can't be built, a hint says why
| Hint | What to do |
|---|---|
| Select an active connection to open endpoints | Pick an active connection, see Switch the active connection |
| Select a site in the Site Scope widget to open endpoints | Pick a site in the Site Scope widget. Global has no storefront URL |
| This route has no name | The declaration has an empty route name. Give it one |
Usages
The usage lens counts the places in your linked cartridges that reference the route:
- Route arguments of calls in scripts, ISML templates and cartridge XML outside
cartridge/forms, such asURLUtils.url('Cart-Show'), including helpers you add in SFCC Route Calls <iscomponent pipeline="Cart-Show">in templates- The start node a pipeline call node or jump node calls
<exec pipeline="..." node="...">in other cartridge XML- Content links such as
$url('Cart-Show')$in templates and in site archive XML, also XML outside your cartridges
Click the lens to list them with the file, line number and code of each. Type to filter the list. A single usage opens right away, and with none a hint shows No usages of Cart-Show
SFRA extensions
On an SFRA route, the prepend, append and replace lenses count the other declarations of the same route that use that method, such as server.append('Show', ...) in app_custom for the Cart-Show of app_storefront_base. Click one to list them by cartridge. A single target opens right away
The targets follow the cartridge path of the site selected in the Site Scope widget, and cartridges outside that path drop out. With Global scope, or a site without cartridges, every target shows in project order
Pipeline start nodes
Open a pipeline's XML with Show Pipeline Source from the right-click menu of the file. Each named start node, private ones too, gets Open Endpoint, Copy Endpoint URL and the usage lens above its <branch>. SiteGenesis controller routes get the same three lenses
Hooks
A script that hooks.json names as a hook script gets a lens above its hook functions
- For a Salesforce hook point, such as
dw.order.calculate, the lens dw.order.calculate sits above the function its name ends with,calculate - For a custom hook, every exported function gets a lens with the hook and the function, such as app.loyalty.points.earn → earn
Click a lens to open hooks.json with the hook's whole entry selected
Step types
A module that a step type in steptypes.json runs gets a lens above each function the step type names. It reads the step type ID and the key that names the function, such as custom.Loyalty-SyncMembers → readFunction. A script step that names no function gets its lens on execute, and the click opens its @type-id
Key in steptypes.json | Lens |
|---|---|
function | function |
read-function | readFunction |
process-function | processFunction |
write-function | writeFunction |
total-count-function | totalCountFunction |
before-step-function | beforeStepFunction |
before-chunk-function | beforeChunkFunction |
after-chunk-function | afterChunkFunction |
after-step-function | afterStepFunction |
A function gets one lens, from the first step type that names it in cartridge order. Click it to open steptypes.json at the function name
The other way round, steptypes.json has a gutter icon next to module and next to each function key, which opens the script and the function, see Gutter icons
Jobs that run a step type
In steptypes.json, each step type shows used by 1 job or used by N jobs, counted from the jobs XML of the project. The tooltip says how many steps run it. A click opens the step in the Jobs editor, or the popup Steps Running custom.Acme.UpdateOrders when several steps do
Page Designer types
The JSON of a Page Designer page or component type shows used by N pages or used by N components, counted from the library XML of the project. A click opens the content in the Library Editor, or the popup Library Contents of the type when there are several. The lens waits for indexing and needs a license
Custom APIs
The api.json, schema.yaml and script of a custom API link to each other with a gutter icon instead of lenses, in files of the same cartridge. Hover the icon to see its links, such as Implementation getPoints in script.js. A click opens the only link, or lists them under Custom API getPoints with the file, line and code of each
| File | Line | Links to |
|---|---|---|
api.json | endpoint | The function of the script, also when the script registers it with app.handle, and each operation in schema.yaml, such as GET /members/{memberId}/points |
schema.yaml | Each operation, such as get: | The function of the script and the endpoint in api.json |
| Script | The endpoint function | Each operation in schema.yaml and the endpoint in api.json |
The icons follow edits to any of the three files. Turn them off in Settings › Editor › General › Gutter Icons › SFCC custom API links
Every value of an api.json endpoint is a link as well. Cmd+Click (Ctrl+Click) on endpoint opens the function of the script and each operation of the schema, on schema the schema and on implementation the script. schema and implementation also get a gutter icon to their file. endpoint completes the operation IDs of the schema and implementation completes script paths without the extension. A path that names no file turns red
Request hints
After each endpoint, a hint shows the request of every schema operation with that operation ID, such as POST /loyalty. Hover a hint to see the URL a client calls, such as https://{shortCode}.api.commercecloud.salesforce.com/custom/loyalty/v1/organizations/{organizationId}/loyalty. Click it to open the operation in schema.yaml
Turn the hints off in Settings › Editor › Inlay Hints › URL path › SFCC custom API requests
Cartridge path
In a site.xml, <custom-cartridges> under <site> gets a lens such as Edit cartridge path: RefArch (3), with the site-id and the number of cartridges on the path. In a preferences.xml, <preference preference-id="CustomCartridges"> gets Edit cartridge path: Business Manager (2)
Click it to open the Cartridge Path Editor for that path. Unlike the other lenses, this one stays while the IDE indexes
Several lenses on one line
When two lenses of the same kind land on one line, they share it, joined by ·, such as dw.order.calculate · app.loyalty.points.earn → calculate. A click opens a list to choose from
Troubleshooting
| Symptom | What to do |
|---|---|
| No lenses at all | Check that the license or trial is valid and that the file is in a linked cartridge, see Which files have lenses. Check the group in Settings › Editor › Inlay Hints › Code vision |
| The lenses disappeared for a moment | The IDE is indexing. They come back when it finishes |
| A usage count is lower than expected | Calls through your own helper count only with a rule in SFCC Route Calls. Files outside linked cartridges don't count, except content links in site archive XML |
| An append lens is missing | The other cartridge isn't on the selected site's cartridge path. Select Global in the Site Scope widget to see every cartridge |
No request hints after an endpoint | The schema needs an operation whose operationId is the endpoint. Check Settings › Editor › Inlay Hints › URL path |
| A click shows File not found and a path | The file moved or was deleted since the lens was drawn. Edit the file or reopen it to refresh the lenses |
Related
Search Everywhere
Find every entry point by name in the B2C Entry Points tab
B2C Entry Points
Every entry point of your cartridges in one tool window
Search & Navigation
Cartridge labels, gutter icons and Go to Declaration
Site Scopes
The site that orders SFRA targets and builds endpoint URLs
Cartridge Path Editor
Where the cartridge path lens takes you
ISML navigation
Code Vision, gutter icons and Find Usages in templates