Hooks, Routes, Jobs & APIs

Connect SFCC registrations, exported functions, routes, templates, resources, and custom API operations across your cartridges

SFCC connects many features through strings and configuration files. IntelliJ SFCC indexes those relationships so completion can suggest valid names and navigation can take you from a caller or registration to the implementation.

System and custom hooks

Hook intelligence starts with a recognized hooks.json registration and its script. Known system-hook signatures can supply parameter and return types to the registered implementation without adding JSDoc yourself.

cartridge/hooks.json
{
  "hooks": [
    {
      "name": "dw.order.calculate",
      "script": "./scripts/hooks/calculate"
    }
  ]
}

Keep your cartridge's normal hook-file registration in place so SFCC can load it at runtime. Local indexing does not deploy or enable a hook on the sandbox.

cartridge/scripts/hooks/calculate.js
var Status = require('dw/system/Status');

exports.calculate = function (basket) {
    // Demonstrates typing only; real basket calculation belongs here.
    var currency = basket.currencyCode;
    return new Status(Status.OK);
};

For this known hook, basket is modeled as dw.order.Basket and the expected result is dw.system.Status. Completion after exports. can suggest known hook functions not already exported.

var HookMgr = require('dw/system/HookMgr');
var BasketMgr = require('dw/order/BasketMgr');
var basket = BasketMgr.getCurrentBasket();

if (basket && HookMgr.hasHook('dw.order.calculate')) {
    HookMgr.callHook('dw.order.calculate', 'calculate', basket);
}

The hook-name argument completes from indexed hooks; the function argument can complete from the selected hook. Use Go to Definition to inspect its implementation.

For custom hooks, registered names and indexed exports remain navigable. Write JSDoc or TypeScript annotations for your own contract where the server has no known system signature; it cannot infer a domain model from the hook's name alone.

Hook CodeLens provides the reverse path from the implementation to its registration.

SFRA, SiteGenesis, and pipeline routes

Route intelligence recognizes SFRA controller declarations, SiteGenesis endpoints, and pipeline entry points. Completion details identify the kind of route and its cartridge context.

var URLUtils = require('dw/web/URLUtils');
var productUrl = URLUtils.url('Product-Show', 'pid', 'demo-product');

Place the caret inside 'Product-Show' and invoke completion, or use Go to Definition on it. Find All References and the route's usage lens help locate indexed callers. For SFRA, append, prepend, and replace relationships are available through route CodeLens.

In SiteGenesis controllers, exported route functions can expose a .public flag. The engine models that member and checks boolean-compatible assignments. This is separate from an SFRA server.get declaration or a public pipeline start node.

Job step registrations

In steptypes.json, module fields complete to cartridge scripts, and function fields can complete to the module's exports. Definition navigation connects those configuration values to code.

The relationship includes task-oriented steps and chunk-oriented lifecycle functions. Step CodeLens connects a script export back to the registered step type and its role. Keep names consistent across the JSON and script; renaming a function manually does not automatically rewrite every registration.

Custom APIs

Custom API support indexes api.json, the associated OpenAPI YAML, and implementation scripts. It connects endpoint identifiers, operation declarations, and exported handlers.

Where you workUse the connection to…
api.jsonComplete relevant endpoint wiring and navigate to the indexed implementation or schema.
OpenAPI operationInspect the operation's implementation and registration through CodeLens.
Exported handlerReturn to the schema or registration to understand the HTTP contract.

These features describe indexed endpoint relationships. They do not establish that an API is registered or authorized on the active sandbox. See Hooks, routes & custom APIs for the companion panels.

Templates and localized resources

Use the same completion-and-definition workflow for rendered templates and resource messages:

var Resource = require('dw/web/Resource');

// Within an SFRA route handler:
res.render('product/details', {
    heading: Resource.msg('product.details.title', 'product', null)
});
StringSource of intelligence
'product/details'Indexed .isml templates; inserted paths omit the extension.
'product.details.title'Keys in indexed .properties resource bundles.
'product'Resource bundle names and available locale variants.

Find All References on a resource key locates recognized usages. The resource lenses show usage and localization counts from the .properties declaration.

If a project wraps these APIs in its own helpers, completion-context rules let you identify the relevant method and argument position.

Forms and pipeline dictionaries

Two additional contracts generate typed values from project declarations:

On this page