agent-docs 1.0.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/.cursor/plans/OPTIMISE.md +379 -0
- package/.cursor/plans/VERSIONING.md +207 -0
- package/.cursor/rules/IMPORTANT.mdc +97 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +13 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- package/.github/dependabot.yml +38 -0
- package/.github/pull_request_template.md +10 -0
- package/.github/workflows/format.yml +35 -0
- package/CODE_OF_CONDUCT.md +64 -0
- package/CONTRIBUTING.md +52 -0
- package/LICENSE.md +20 -0
- package/PLAN.md +707 -0
- package/README.md +133 -0
- package/SECURITY.md +21 -0
- package/docs/APEXANNOTATIONS.md +472 -0
- package/docs/APEXDOC.md +198 -0
- package/docs/CML.md +877 -0
- package/docs/CODEANALYZER.md +435 -0
- package/docs/CONTEXTDEFINITIONS.md +617 -0
- package/docs/ESLINT.md +827 -0
- package/docs/ESLINTJSDOC.md +520 -0
- package/docs/FIELDSERVICE.md +4452 -0
- package/docs/GRAPHBINARY.md +208 -0
- package/docs/GRAPHENGINE.md +616 -0
- package/docs/GRAPHML.md +337 -0
- package/docs/GRAPHSON.md +302 -0
- package/docs/GREMLIN.md +490 -0
- package/docs/GRYO.md +232 -0
- package/docs/HUSKY.md +106 -0
- package/docs/JEST.md +387 -0
- package/docs/JORJE.md +537 -0
- package/docs/JSDOC.md +621 -0
- package/docs/PMD.md +910 -0
- package/docs/PNPM.md +409 -0
- package/docs/PRETTIER.md +716 -0
- package/docs/PRETTIERAPEX.md +874 -0
- package/docs/REVENUETRANSACTIONMANAGEMENT.md +887 -0
- package/docs/TINKERPOP.md +252 -0
- package/docs/VITEST.md +706 -0
- package/docs/VSCODE.md +231 -0
- package/docs/XPATH31.md +213 -0
- package/package.json +32 -0
- package/postinstall.mjs +51 -0
- package/prettier.config.js +18 -0
|
@@ -0,0 +1,887 @@
|
|
|
1
|
+
# Salesforce Revenue Cloud: Transaction Management
|
|
2
|
+
|
|
3
|
+
> v1.0.0 | Editions: Enterprise, Unlimited, Developer (Lightning Experience)
|
|
4
|
+
|
|
5
|
+
## Quick Reference
|
|
6
|
+
|
|
7
|
+
### Object Flow
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
Opportunity → Quote → Order → Contract → Asset
|
|
11
|
+
QuoteLineItem → OrderItem → ContractItemPrice → Asset
|
|
12
|
+
Product2 → PricebookEntry → QuoteLineItem/OrderItem
|
|
13
|
+
Asset → AssetAction → AssetStatePeriod
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Core APIs
|
|
17
|
+
|
|
18
|
+
| API | Purpose | Endpoint |
|
|
19
|
+
| ---------------------------- | ----------------------------- | --------------------------------------------------------------------------------------------------- |
|
|
20
|
+
| CalculatePrice | Pricing calculations | `POST /actions/custom/CalculatePrice` |
|
|
21
|
+
| CloneSalesTransaction | Clone transactions | `POST /connect/rev/sales-transaction/actions/clone` |
|
|
22
|
+
| CreateRampDeal | Create ramp deal | `POST /connect/revenue-management/sales-transaction-contexts/{resourceId}/actions/ramp-deal-create` |
|
|
23
|
+
| CreateSubscriptionRecords | Create subscription records | `POST /actions/custom/CreateSubscriptionRecords` |
|
|
24
|
+
| DeleteRampDeal | Delete ramp deal | `POST /connect/revenue-management/sales-transaction-contexts/{resourceId}/actions/ramp-deal-delete` |
|
|
25
|
+
| GetInstantPrice | Real-time pricing | `POST /industries/cpq/quotes/actions/get-instant-price` |
|
|
26
|
+
| GetRenewableAssetsSummary | Get renewable assets summary | `POST /actions/custom/GetRenewableAssetsSummary` |
|
|
27
|
+
| PlaceOrder | Order operations | `POST /commerce/sales-orders/actions/place` |
|
|
28
|
+
| PlaceQuote | Quote operations | `POST /commerce/quotes/actions/place` |
|
|
29
|
+
| PlaceSalesTransaction | Create/update quotes & orders | `POST /actions/custom/PlaceSalesTransaction` |
|
|
30
|
+
| PlaceSupplementalTransaction | Supplemental orders | `POST /connect/rev/sales-transaction/actions/place-supplemental-transaction` |
|
|
31
|
+
| PreviewApprovals | Preview approval chains | `POST /actions/custom/PreviewApprovals` |
|
|
32
|
+
| ReadSalesTransaction | Read transaction data | `POST /connect/revenue/transaction-management/sales-transactions/actions/read` |
|
|
33
|
+
| SubmitOrder | Submit for fulfillment | `POST /actions/custom/SubmitOrder` |
|
|
34
|
+
| UpdateRampDeal | Update ramp deal | `POST /connect/revenue-management/sales-transaction-contexts/{resourceId}/actions/ramp-deal-update` |
|
|
35
|
+
| ViewRampDeal | View ramp deal | `GET /connect/revenue-management/sales-transaction-contexts/{resourceId}/actions/ramp-deal-view` |
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Connect API Resources
|
|
40
|
+
|
|
41
|
+
| Resource | Method | Description |
|
|
42
|
+
| ------------------------------ | ------ | ----------------------------------------------------------------------- |
|
|
43
|
+
| Asset Amendment | POST | Initiate and execute the amendment of a quote or an order |
|
|
44
|
+
| Asset Cancellation | POST | Initiate and execute the cancellation of an asset |
|
|
45
|
+
| Asset Renewal | POST | Initiate and execute the renewal of an asset |
|
|
46
|
+
| Clone Sales Transaction | POST | Clone quote/order line item with related records and configurations |
|
|
47
|
+
| Create Ramp Deal | POST | Create multi-segment pricing deal with different attributes per segment |
|
|
48
|
+
| Delete Ramp Deal | POST | Delete ramp deal, converting ramped product to single line item |
|
|
49
|
+
| Instant Pricing | POST | Fetch instant pricing data, create or update context |
|
|
50
|
+
| Place Order | POST | Place orders with integrated pricing, configuration, and validation |
|
|
51
|
+
| Place Quote | POST | Create quote to discover and price products/services |
|
|
52
|
+
| Place Sales Transaction | POST | Create sales transaction with integrated pricing and configuration |
|
|
53
|
+
| Place Supplemental Transaction | POST | Create supplemental/change orders after submission |
|
|
54
|
+
| Preview Approval | POST | Preview approval levels, chains, approvers, and conditions |
|
|
55
|
+
| Read Sales Transaction | POST | Retrieve sales transaction data from initialized/hydrated context |
|
|
56
|
+
| Update Ramp Deal | POST | Modify ramp deal segments (quantity, discount, dates) |
|
|
57
|
+
| View Ramp Deal | GET | View ramp deal related to quote/order line item |
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Apex Namespaces
|
|
62
|
+
|
|
63
|
+
### Namespace Summary
|
|
64
|
+
|
|
65
|
+
| Namespace | Purpose | Key Use Cases |
|
|
66
|
+
| ---------------- | --------------------------------------- | ------------------------------------------------------- |
|
|
67
|
+
| `CommerceOrders` | Order management (Deprecated API 63.0+) | Use RevSalesTrxn instead |
|
|
68
|
+
| `CommerceTax` | Tax calculations | External tax engine integration |
|
|
69
|
+
| `ConnectApi` | Asset operations | Transfer assets between accounts |
|
|
70
|
+
| `Functions` | Heavy processing | Offload complex calculations |
|
|
71
|
+
| `Invocable` | Flow integration | Call invocable actions from Apex |
|
|
72
|
+
| `Messaging` | Notifications | Send email notifications |
|
|
73
|
+
| `Metadata` | Configuration | Read/manage custom metadata types |
|
|
74
|
+
| `PlaceQuote` | Quote creation (Deprecated API 63.0+) | Use RevSalesTrxn instead |
|
|
75
|
+
| `Process` | Flow data exchange | Pass data between Apex and Flow |
|
|
76
|
+
| `RevSalesTrxn` | Core transaction ops | Create/update quotes & orders, pricing, asset lifecycle |
|
|
77
|
+
|
|
78
|
+
### RevSalesTrxn (Primary)
|
|
79
|
+
|
|
80
|
+
Create sales transactions (quote/order) with integrated pricing and
|
|
81
|
+
configuration.
|
|
82
|
+
|
|
83
|
+
**Core Classes:**
|
|
84
|
+
|
|
85
|
+
- `CalculatePriceRequest` / `CalculatePriceResponse`
|
|
86
|
+
- `Error` — Error details structure
|
|
87
|
+
- `GetRenewableAssetsSummaryRequest` / `GetRenewableAssetsSummaryResponse`
|
|
88
|
+
- `InitiateAmendmentRequest` / `InitiateAmendmentResponse`
|
|
89
|
+
- `InitiateCancellationRequest` / `InitiateCancellationResponse`
|
|
90
|
+
- `InitiateRenewalRequest` / `InitiateRenewalResponse`
|
|
91
|
+
- `PlaceSalesTransactionRequest` / `PlaceSalesTransactionResponse`
|
|
92
|
+
- `PricingResult` — Pricing calculation result structure
|
|
93
|
+
- `ReadSalesTransactionRequest` / `ReadSalesTransactionResponse`
|
|
94
|
+
- `SubmitOrderRequest` / `SubmitOrderResponse`
|
|
95
|
+
- `TransactionException` — Custom exception class
|
|
96
|
+
|
|
97
|
+
**Additional Classes:**
|
|
98
|
+
|
|
99
|
+
| Class | Purpose |
|
|
100
|
+
| -------------------------------- | ------------------------------------------------------------------------------------------------ |
|
|
101
|
+
| `ConfigurationOptionsInput` | Configuration options for product configurator input |
|
|
102
|
+
| `GraphRequest` | Graph ID and records list for ingestion |
|
|
103
|
+
| `PlaceSalesTransactionException` | Exception details for place sales transaction |
|
|
104
|
+
| `PlaceSalesTransactionExecutor` | Execute place sales transaction with graph request, pricing, config |
|
|
105
|
+
| `PlaceSalesTransactionResponse` | Response with contextDetails, errorResponse, isSuccess, salesTransactionId, statusUrl, trackerId |
|
|
106
|
+
| `RecordResource` | Create record object from sales transaction field values |
|
|
107
|
+
| `RecordWithReferenceRequest` | Associate record object with reference identifier |
|
|
108
|
+
|
|
109
|
+
**ConfigurationOptionsInput Properties:** | Property | Type | Description |
|
|
110
|
+
|----------|------|-------------| | `addDefaultConfiguration` | Boolean |
|
|
111
|
+
Auto-add default configuration (bundle/product attributes) | |
|
|
112
|
+
`executeConfigurationRules` | Boolean | Require adherence to configuration rules
|
|
113
|
+
| | `validateAmendRenewCancel` | Boolean | Run amend/renew/cancel validations |
|
|
114
|
+
| `validateProductCatalog` | Boolean | Validate against product catalog |
|
|
115
|
+
|
|
116
|
+
**PlaceSalesTransactionExecutor.execute() Parameters:**
|
|
117
|
+
|
|
118
|
+
- `graphRequest` (GraphRequest) — sObject graph values of order payload
|
|
119
|
+
- `pricingPreferenceEnum` (PricingPreferenceEnum) — Pricing preference
|
|
120
|
+
- `configurationExecutionEnum` (ConfigurationExecutionEnum) — Configuration
|
|
121
|
+
method
|
|
122
|
+
- `configuratorOptions` (ConfigurationOptionsInput) — Configuration options
|
|
123
|
+
- `id` (String) — ID to assign to sales transaction
|
|
124
|
+
- `catalogRatesPreferenceEnum` (CatalogRatesPreferenceEnum) — Rate card entries
|
|
125
|
+
preference (optional)
|
|
126
|
+
|
|
127
|
+
**Enums:** | Enum | Values | Description | |------|--------|-------------| |
|
|
128
|
+
`CatalogRatesPreferenceEnum` | `Fetch`, `Skip` | Rate card entries for
|
|
129
|
+
usage-based selling | | `ConfigurationExecutionEnum` | `RunAndAllowErrors`,
|
|
130
|
+
`RunAndBlockErrors`, `Skip` | Configuration execution mode | |
|
|
131
|
+
`PricingPreferenceEnum` | `Force`, `Skip`, `System` | Pricing preference during
|
|
132
|
+
transaction |
|
|
133
|
+
|
|
134
|
+
### CommerceTax
|
|
135
|
+
|
|
136
|
+
Manages communication between Salesforce and external tax engines.
|
|
137
|
+
|
|
138
|
+
**Classes:** | Class | Purpose | |-------|---------| | `AddressesResponse` |
|
|
139
|
+
Ship To, Ship From, Sold To address responses | | `AmountDetailsResponse` | Tax
|
|
140
|
+
amount, total with tax, exempt amount | | `CustomTaxAttributesResponse` |
|
|
141
|
+
Additional custom tax attributes | | `DocumentCodeRequest` | Document code for
|
|
142
|
+
tax calculation | | `ExemptDetailsResponse` | Exemption ID, number, reason | |
|
|
143
|
+
`ImpositionResponse` | Tax imposition details (id, name, type, subType) | |
|
|
144
|
+
`JurisdictionResponse` | Tax jurisdiction (country, region, state, level) | |
|
|
145
|
+
`LineItemResponse` | Line item tax calculation results | |
|
|
146
|
+
`LineTaxAddressesRequest` | Per-line-item addresses for tax calculation | |
|
|
147
|
+
`RuleDetailsResponse` | Tax rules used (nonTaxableRuleId, rateRuleId,
|
|
148
|
+
rateSourceId) | | `TaxAddressesRequest` | Ship From/To, Sold To, Bill To
|
|
149
|
+
addresses | | `TaxAddressRequest` | Address details (city, country, state,
|
|
150
|
+
postalCode, lat/long) | | `TaxApiException` | Tax calculation exceptions | |
|
|
151
|
+
`TaxCustomerDetailsRequest` | Customer details (accountId, code,
|
|
152
|
+
exemptionNo/Reason) | | `TaxDetailsResponse` | Tax calculation details per line
|
|
153
|
+
| | `TaxEngineRequest` | Tax engine request payload | | `TaxEngineResponse` |
|
|
154
|
+
Tax engine response |
|
|
155
|
+
|
|
156
|
+
**TaxAddressRequest Properties:** `city`, `country`, `countryCode`, `latitude`,
|
|
157
|
+
`locationCode`, `longitude`, `postalCode`, `state`, `stateCode`, `street`
|
|
158
|
+
|
|
159
|
+
### PlaceQuote (Deprecated API 63.0+)
|
|
160
|
+
|
|
161
|
+
**Note:** Use RevSalesTrxn instead for API 63.0+.
|
|
162
|
+
|
|
163
|
+
**Classes:**
|
|
164
|
+
|
|
165
|
+
- `GraphRequest` — Graph ID and records for quote ingestion
|
|
166
|
+
- `PlaceQuoteRLMApexProcessor` — Execute Place Quote Apex API
|
|
167
|
+
- `PlaceQuoteResponse` — Response with contextDetails, errorResponse, isSuccess,
|
|
168
|
+
quoteId
|
|
169
|
+
- `RecordResource` — Create record from quote field values
|
|
170
|
+
- `RecordWithReferenceRequest` — Associate record with reference ID
|
|
171
|
+
|
|
172
|
+
**Enums:** | Enum | Values | |------|--------| | `CatalogRatesPreferenceEnum` |
|
|
173
|
+
`Fetch`, `Skip` | | `ConfigurationInputEnum` | `RunAndAllowErrors`,
|
|
174
|
+
`RunAndBlockErrors`, `Skip` | | `PricingPreferenceEnum` | `Force`, `Skip`,
|
|
175
|
+
`System` |
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Objects Reference
|
|
180
|
+
|
|
181
|
+
### Standard Objects (Referenced)
|
|
182
|
+
|
|
183
|
+
- **Account** — Customer account (Lookup from Quote, Order, Contract, Asset)
|
|
184
|
+
- **Opportunity** — Sales opportunity (Lookup from Quote, Order)
|
|
185
|
+
- **Pricebook2** — Price book (Lookup from Quote, Order)
|
|
186
|
+
- **PricebookEntry** — Product price in price book (Lookup from QuoteLineItem,
|
|
187
|
+
OrderItem)
|
|
188
|
+
- **Product2** — Product catalog (Lookup from QuoteLineItem, OrderItem)
|
|
189
|
+
|
|
190
|
+
### Asset Objects
|
|
191
|
+
|
|
192
|
+
| Object | Description | API Ver |
|
|
193
|
+
| -------------------------- | ------------------------------ | ------- |
|
|
194
|
+
| `Asset` | Delivered product/service | - |
|
|
195
|
+
| `AssetAction` | Changes (amend, renew, cancel) | - |
|
|
196
|
+
| `AssetActionSource` | Source of asset action | - |
|
|
197
|
+
| `AssetRateCardEntry` | Rate card for assets | v62+ |
|
|
198
|
+
| `AssetRelationship` | Asset hierarchies/bundles | - |
|
|
199
|
+
| `AssetStatePeriod` | Asset state over time | - |
|
|
200
|
+
| `AssetUsageResourceGrant` | Usage grants | v65+ |
|
|
201
|
+
| `AssetUsageResourcePolicy` | Usage policies | v65+ |
|
|
202
|
+
|
|
203
|
+
**Key Fields:** `CurrentAmount`, `CurrentMrr`, `CurrentQuantity`,
|
|
204
|
+
`LifecycleEndDate`, `LifecycleStartDate`, `PurchaseDate`, `Status`,
|
|
205
|
+
`TotalLifecycleAmount`, `UsageEndDate`
|
|
206
|
+
|
|
207
|
+
**Lifecycle States:** `Draft` → `Purchased` → `Installed` → `Active` →
|
|
208
|
+
`Cancelled`/`Expired`
|
|
209
|
+
|
|
210
|
+
**Action Types:** `Amend`, `Cancel`, `Renew`, `Rollback`, `Transfer`
|
|
211
|
+
|
|
212
|
+
### Contract Objects
|
|
213
|
+
|
|
214
|
+
| Object | Description | API Ver |
|
|
215
|
+
| ------------------------- | -------------------------- | ------- |
|
|
216
|
+
| `Contract` | Customer agreement | - |
|
|
217
|
+
| `ContractAction` | Actions on contracts | - |
|
|
218
|
+
| `ContractItemPrice` | Pricing for contract items | - |
|
|
219
|
+
| `ContractPricingSchedule` | Pricing schedules | - |
|
|
220
|
+
|
|
221
|
+
**Key Fields:** `BillingAccount`, `ContractTerm`, `EndDate`, `StartDate`,
|
|
222
|
+
`Status`
|
|
223
|
+
|
|
224
|
+
### Order Objects
|
|
225
|
+
|
|
226
|
+
| Object | Description | API Ver |
|
|
227
|
+
| ------------------------- | ---------------------------------- | ------- |
|
|
228
|
+
| `Order` | Confirmed product/service request | - |
|
|
229
|
+
| `OrderAction` | Actions on order (submit, cancel) | - |
|
|
230
|
+
| `OrderItem` | Individual products in order | - |
|
|
231
|
+
| `OrderItemAttribute` | Virtual object for item attributes | v59+ |
|
|
232
|
+
| `OrderItemDetail` | Item breakdown details | v60+ |
|
|
233
|
+
| `OrderItemGroup` | Groups items for fulfillment | v61+ |
|
|
234
|
+
| `OrderItemRateAdjustment` | Negotiated rate adjustments | v62+ |
|
|
235
|
+
| `OrderItemRateCardEntry` | Usage rates for order items | v62+ |
|
|
236
|
+
| `OrdItmUsageRsrcPlcy` | Usage resource policies | v65+ |
|
|
237
|
+
| `OrdItmUseRsrcGrant` | Usage resource grants | v65+ |
|
|
238
|
+
|
|
239
|
+
**Key Fields:** `CalculationStatus`, `EffectiveDate`, `EndDate`,
|
|
240
|
+
`FulfillmentStatus`, `IsReductionOrder`, `OrderReferenceNumber`,
|
|
241
|
+
`OriginalActionType`, `SalesTransactionTypeId`, `Status`, `TotalAmount`,
|
|
242
|
+
`TransactionType`
|
|
243
|
+
|
|
244
|
+
**Status Values:** `Activated`, `Cancelled`, `Completed`, `Draft`, `In Progress`
|
|
245
|
+
|
|
246
|
+
**CalculationStatus Values:** `CompletedWithPricing`, `CompletedWithTax`,
|
|
247
|
+
`InProgress`, `NotStarted`, `PriceCalculationFailed`, `TaxCalculationFailed`
|
|
248
|
+
|
|
249
|
+
### Quote Objects
|
|
250
|
+
|
|
251
|
+
| Object | Description | API Ver |
|
|
252
|
+
| -------------------------- | --------------------------------------- | ------- |
|
|
253
|
+
| `Quote` | Proposal with products/pricing | - |
|
|
254
|
+
| `QuoteAction` | Sales transaction type (renewal, etc.) | v59+ |
|
|
255
|
+
| `QuoteDocument` | PDF generated from quote | - |
|
|
256
|
+
| `QuoteLineDetail` | Pricing/quantity breakdown | v60+ |
|
|
257
|
+
| `QuoteLineGroup` | Groups line items, stores subtotals | v61+ |
|
|
258
|
+
| `QuoteLineItem` | Individual products in quote | - |
|
|
259
|
+
| `QuoteLineItemAttribute` | Virtual object for line item attributes | v59+ |
|
|
260
|
+
| `QuoteLineRateAdjustment` | Negotiated rate adjustments | v62+ |
|
|
261
|
+
| `QuoteLineRateCardEntry` | Catalog/negotiated rates for usage | v62+ |
|
|
262
|
+
| `QuotLineItmUsageRsrcPlcy` | Usage resource policies | v65+ |
|
|
263
|
+
| `QuotLineItmUseRsrcGrant` | Usage resource grants | v65+ |
|
|
264
|
+
|
|
265
|
+
**Key Fields:** `Discount`, `ListPrice`, `Product2Id`, `Quantity`, `Subtotal`,
|
|
266
|
+
`TotalPrice`, `UnitPrice`
|
|
267
|
+
|
|
268
|
+
**Relationships:**
|
|
269
|
+
|
|
270
|
+
- `Account` (Lookup) → customer
|
|
271
|
+
- `Opportunity` (Lookup) → sales opportunity
|
|
272
|
+
- `Order` (Lookup) → converted order
|
|
273
|
+
- `QuoteDocument` (Master-Detail) → PDF docs
|
|
274
|
+
- `QuoteLineGroup` (Master-Detail) → grouped items
|
|
275
|
+
- `QuoteLineItem` (Master-Detail) → products
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## Input/Output Structures
|
|
280
|
+
|
|
281
|
+
### Input Structures Summary
|
|
282
|
+
|
|
283
|
+
| Structure | Description |
|
|
284
|
+
| ------------------------------ | ---------------------------------------------------- |
|
|
285
|
+
| Amendment Input | Request to create amendment record |
|
|
286
|
+
| Cancellation Input | Request to cancel quote/order |
|
|
287
|
+
| Clone Options Input | Options for cloning sales transaction |
|
|
288
|
+
| Clone Sales Transaction Input | Request to clone transaction records |
|
|
289
|
+
| Configuration Options Input | Configuration options for request |
|
|
290
|
+
| Configurator Preference Input | Configuration preference for place sales transaction |
|
|
291
|
+
| Context Input | Context associated with sales transaction |
|
|
292
|
+
| Context Node Input | Context nodes for ramp segments |
|
|
293
|
+
| Create Ramp Deal Input | Request to create ramp deal |
|
|
294
|
+
| Delete Ramp Deal Input | Request to delete ramp deal |
|
|
295
|
+
| Execution Settings Input | Execution settings for ramp deal |
|
|
296
|
+
| Instant Pricing Input | Request for instant pricing details |
|
|
297
|
+
| Object Graph Input | sObject with graph ID |
|
|
298
|
+
| Object Input Map | sObject record in key-value map format |
|
|
299
|
+
| Object with Reference Input | Records list for insert/update |
|
|
300
|
+
| Place Order Input | Request to create/update order |
|
|
301
|
+
| Place Quote Input | Request to create/update quote |
|
|
302
|
+
| Preview Approval Input | Request to preview approval |
|
|
303
|
+
| Read Sales Transaction Input | Filter criteria to read sales transaction |
|
|
304
|
+
| Renewal Input | Request to initiate asset renewal |
|
|
305
|
+
| Sales Transaction Input | Request to place sales transaction |
|
|
306
|
+
| Supplemental Transaction Input | Request to create supplemental order |
|
|
307
|
+
| Update Ramp Deal Input | Request to update ramp deal |
|
|
308
|
+
|
|
309
|
+
### Detailed Input Structures
|
|
310
|
+
|
|
311
|
+
#### SalesTransactionInput
|
|
312
|
+
|
|
313
|
+
```apex
|
|
314
|
+
String transactionType; // Required: NewQuote, NewOrder, UpdateQuote, UpdateOrder, Amendment, Renewal, Cancellation
|
|
315
|
+
Map<String, List<Map<String, Object>>> records; // Required: Object data keyed by API name
|
|
316
|
+
String contextId; // Optional: Reuse existing context
|
|
317
|
+
String pricingProcedureId; // Optional: Specific pricing procedure
|
|
318
|
+
Boolean skipPricingCalculation; // Optional
|
|
319
|
+
Boolean skipTaxCalculation; // Optional
|
|
320
|
+
Map<String, Object> options; // Optional: Configuration options
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
#### AmendmentInput / CancellationInput / RenewalInput
|
|
324
|
+
|
|
325
|
+
```apex
|
|
326
|
+
// AmendmentInput
|
|
327
|
+
List<Id> assetIds; // Required
|
|
328
|
+
Date amendmentDate; // Required
|
|
329
|
+
String amendmentType; // Optional
|
|
330
|
+
Map<String, Object> options;
|
|
331
|
+
|
|
332
|
+
// CancellationInput
|
|
333
|
+
List<Id> assetIds; // Required
|
|
334
|
+
Date cancellationDate; // Required
|
|
335
|
+
String cancellationReason; // Optional
|
|
336
|
+
Map<String, Object> options;
|
|
337
|
+
|
|
338
|
+
// RenewalInput
|
|
339
|
+
List<Id> assetIds; // Required
|
|
340
|
+
Date renewalDate; // Required
|
|
341
|
+
Integer renewalTerm; // Optional: months
|
|
342
|
+
Map<String, Object> options;
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
#### CloneSalesTransactionInput
|
|
346
|
+
|
|
347
|
+
```apex
|
|
348
|
+
Id salesTransactionId; // Required
|
|
349
|
+
CloneOptionsInput cloneOptions; // Optional
|
|
350
|
+
Map<String, Object> overrideFields; // Optional
|
|
351
|
+
Boolean cloneLineItems; // Optional
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
#### CreateRampDealInput
|
|
355
|
+
|
|
356
|
+
```apex
|
|
357
|
+
Id resourceId; // Required: QuoteLineItem or OrderItem ID
|
|
358
|
+
List<RampDealSegment> segments; // Required
|
|
359
|
+
|
|
360
|
+
// RampDealSegment
|
|
361
|
+
Date startDate; // Required
|
|
362
|
+
Date endDate; // Required
|
|
363
|
+
Decimal discount; // Optional
|
|
364
|
+
Decimal quantity; // Optional
|
|
365
|
+
Decimal unitPrice; // Optional
|
|
366
|
+
Map<String, Object> attributes;
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
#### CreateSubscriptionRecordsInput
|
|
370
|
+
|
|
371
|
+
```apex
|
|
372
|
+
Id orderId; // Required: Source order
|
|
373
|
+
List<Map<String, Object>> subscriptions; // Required: Subscription data
|
|
374
|
+
Map<String, Object> options; // Optional: Configuration options
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
#### GetRenewableAssetsSummaryInput
|
|
378
|
+
|
|
379
|
+
```apex
|
|
380
|
+
Id accountId; // Optional: Filter by account
|
|
381
|
+
Id contractId; // Optional: Filter by contract
|
|
382
|
+
Date startDate; // Optional: Start date filter
|
|
383
|
+
Date endDate; // Optional: End date filter
|
|
384
|
+
List<String> assetStatuses; // Optional: Filter by asset status
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
#### PlaceOrderInput
|
|
388
|
+
|
|
389
|
+
```apex
|
|
390
|
+
Id quoteId; // Required
|
|
391
|
+
Id accountId; // Optional: Override account
|
|
392
|
+
Boolean activateOrder; // Optional
|
|
393
|
+
Date effectiveDate; // Optional
|
|
394
|
+
OrderValidationOptions validationOptions; // Optional
|
|
395
|
+
Map<String, Object> orderFields; // Optional
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
#### PlaceQuoteInput
|
|
399
|
+
|
|
400
|
+
```apex
|
|
401
|
+
Id opportunityId; // Required
|
|
402
|
+
Id pricebookId; // Required
|
|
403
|
+
PlaceQuoteOptions options; // Optional
|
|
404
|
+
Map<String, Object> quoteFields; // Optional
|
|
405
|
+
List<Map<String, Object>> lineItems; // Optional
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
#### PreviewApprovalInput
|
|
409
|
+
|
|
410
|
+
```apex
|
|
411
|
+
Id recordId; // Required: Quote or Order ID
|
|
412
|
+
String recordType; // Required: 'Quote' or 'Order'
|
|
413
|
+
Map<String, Object> options; // Optional: Preview options
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
#### ReadSalesTransactionInput
|
|
417
|
+
|
|
418
|
+
```apex
|
|
419
|
+
Id salesTransactionId; // Required
|
|
420
|
+
Boolean includeLineItems; // Optional
|
|
421
|
+
Boolean includeRelatedRecords; // Optional
|
|
422
|
+
List<String> fieldsToRetrieve; // Optional
|
|
423
|
+
Map<String, Object> fieldFilters; // Optional
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
### Response Structures
|
|
427
|
+
|
|
428
|
+
#### Success Response Structures
|
|
429
|
+
|
|
430
|
+
| Structure | Description |
|
|
431
|
+
| ------------------------------ | --------------------------------------------- |
|
|
432
|
+
| Amendment | Details of amendment record |
|
|
433
|
+
| Cancellation | Details of cancellation record |
|
|
434
|
+
| Clone Sales Transaction | Result of cloning records |
|
|
435
|
+
| Instant Pricing | Instant pricing results |
|
|
436
|
+
| Object Reference | sObject with reference ID and potential error |
|
|
437
|
+
| Place Order Response | Create/update order result |
|
|
438
|
+
| Place Quote | Create/update quote result |
|
|
439
|
+
| Preview Approval | Preview approval details |
|
|
440
|
+
| Preview Approval Chain Item | Approval chain item for specific group |
|
|
441
|
+
| Preview Approval Item | Specific approval item within chain |
|
|
442
|
+
| Ramp Deal Service | Created/updated/deleted ramp deal details |
|
|
443
|
+
| Read Sales Transaction | Sales transaction data |
|
|
444
|
+
| Read Sales Transaction Records | Map of record types to record lists |
|
|
445
|
+
| Renewal | Details of renewal record |
|
|
446
|
+
| Sales Transaction | Create sales transaction result |
|
|
447
|
+
| Sales Transaction Context | Context details for sales transaction |
|
|
448
|
+
| Sales Transaction Record | Generic sales transaction record |
|
|
449
|
+
| Supplemental Transaction | Created supplemental order details |
|
|
450
|
+
|
|
451
|
+
#### Error Response Structures
|
|
452
|
+
|
|
453
|
+
| Structure | Description |
|
|
454
|
+
| --------------------------------------- | ------------------------------------ |
|
|
455
|
+
| ARC Base Error | Amendment/renewal/cancellation error |
|
|
456
|
+
| Clone Sales Transaction Error Response | Clone operation errors |
|
|
457
|
+
| Place Order Error Response | Place order errors |
|
|
458
|
+
| Place Quote Error Response | Place quote errors |
|
|
459
|
+
| Preview Approval Error | Preview approval errors |
|
|
460
|
+
| Ramp Deal Service Error Response | Ramp deal processing errors |
|
|
461
|
+
| Sales Transaction Error Response | Place sales transaction errors |
|
|
462
|
+
| Supplemental Transaction Error Response | Supplemental transaction errors |
|
|
463
|
+
|
|
464
|
+
#### Response Field Reference
|
|
465
|
+
|
|
466
|
+
| Structure | Key Fields |
|
|
467
|
+
| ----------------------------------- | -------------------------------------------------------- |
|
|
468
|
+
| `AmendmentResponse` | `success`, `assetActionId`, `quoteId`, `errors[]` |
|
|
469
|
+
| `CalculatePriceResponse` | `success`, `pricingResults[]`, `contextId`, `errors[]` |
|
|
470
|
+
| `CancellationResponse` | `success`, `assetActionId`, `errors[]` |
|
|
471
|
+
| `CloneSalesTransactionResponse` | `success`, `clonedRecords`, `errors[]` |
|
|
472
|
+
| `CreateSubscriptionRecordsResponse` | `success`, `subscriptionIds[]`, `errors[]` |
|
|
473
|
+
| `GetRenewableAssetsSummaryResponse` | `assets[]`, `summary`, `errors[]` |
|
|
474
|
+
| `InstantPricingResponse` | `pricingData`, `contextId`, `errors[]` |
|
|
475
|
+
| `PlaceOrderResponse` | `orderId`, `status`, `errors[]` |
|
|
476
|
+
| `PlaceQuoteResponse` | `quoteId`, `status`, `errors[]` |
|
|
477
|
+
| `PreviewApprovalResponse` | `approvalChains[]`, `approvers[]`, `errors[]` |
|
|
478
|
+
| `RampDealServiceResponse` | `rampDealId`, `segments[]`, `errors[]` |
|
|
479
|
+
| `ReadSalesTransactionResponse` | `records`, `recordTypeMap`, `errors[]` |
|
|
480
|
+
| `RenewalResponse` | `success`, `renewalQuoteId`, `errors[]` |
|
|
481
|
+
| `SalesTransactionResponse` | `success`, `salesTransactionId`, `contextId`, `errors[]` |
|
|
482
|
+
| `SubmitOrderResponse` | `orderId`, `status`, `errors[]` |
|
|
483
|
+
| `SupplementalTransactionResponse` | `orderId`, `status`, `errors[]` |
|
|
484
|
+
|
|
485
|
+
**Error Structure:**
|
|
486
|
+
|
|
487
|
+
```apex
|
|
488
|
+
String errorCode;
|
|
489
|
+
String message;
|
|
490
|
+
List<String> fields;
|
|
491
|
+
String severity; // ERROR, WARNING
|
|
492
|
+
Map<String, Object> errorDetails;
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
### Error Codes
|
|
496
|
+
|
|
497
|
+
| Code | Description | Resolution |
|
|
498
|
+
| --------------------- | ---------------------------------- | ------------------------------------------------- |
|
|
499
|
+
| `CONFIGURATION_ERROR` | Product/transaction config invalid | Review product rules, transaction processing type |
|
|
500
|
+
| `CONTEXT_EXPIRED` | Context ID expired | Create new context |
|
|
501
|
+
| `DUPLICATE_VALUE` | Duplicate value in unique field | Check for existing records |
|
|
502
|
+
| `INVALID_STATE` | Object in invalid state | Check object status, verify workflow state |
|
|
503
|
+
| `LIMIT_ERROR` | Governor limits exceeded | Reduce batch size, optimize queries |
|
|
504
|
+
| `LOCK_ERROR` | Record locked by another process | Retry with backoff |
|
|
505
|
+
| `NOT_FOUND` | Record not found | Verify record ID exists |
|
|
506
|
+
| `PERMISSION_ERROR` | Insufficient permissions | Assign required permission sets |
|
|
507
|
+
| `PRICING_ERROR` | Pricing calculation failed | Verify pricing procedure, check product config |
|
|
508
|
+
| `VALIDATION_ERROR` | Required field missing/invalid | Check request payload, verify field values |
|
|
509
|
+
|
|
510
|
+
---
|
|
511
|
+
|
|
512
|
+
## Invocable Actions
|
|
513
|
+
|
|
514
|
+
| Action | Purpose | Details |
|
|
515
|
+
| ---------------------------------------- | ------------------------------------- | -------------------------------------------------------------------- |
|
|
516
|
+
| `CalculatePriceAction` | Invoke pricing procedures | Calculate prices for quotes/orders |
|
|
517
|
+
| `CancelApprovalSubmissionAction` | Cancel approval submission | Cancels submission and uncompleted child work items |
|
|
518
|
+
| `CreateContractAction` | Create contract from quote | Create contract from specific quote record |
|
|
519
|
+
| `CreateOrderFromQuoteAction` | Convert quote → order | Create order from quote record |
|
|
520
|
+
| `CreateOrderFromQuoteWithOptionsAction` | Quote → order with config | Create order with additional configuration options |
|
|
521
|
+
| `CreateOrdersFromQuoteAction` | Quote → multiple orders | Create multiple orders from single quote |
|
|
522
|
+
| `CreateOrUpdateAssetFromOrderAction` | Create/update assets from order | Create asset per order item; modify for change orders |
|
|
523
|
+
| `CreateOrUpdateAssetFromOrderItemAction` | Create/update assets from order items | Track assets at line item lifecycle stage |
|
|
524
|
+
| `CreateServiceDocumentActions` | Create service documents | Create from work orders, work order line items, service appointments |
|
|
525
|
+
| `GetRenewableAssetsSummaryAction` | Get renewable asset details | Retrieve details for renewal opportunities |
|
|
526
|
+
| `InitiateAmendmentAction` | Start asset amendment | Initiate and execute asset amendment |
|
|
527
|
+
| `InitiateCancellationAction` | Start asset cancellation | Initiate and execute asset cancellation |
|
|
528
|
+
| `InitiateRenewalAction` | Start asset renewal | Initiate and execute asset renewal |
|
|
529
|
+
| `InitiateRollbackOnLastActionAction` | Rollback last asset action | Reverse last action to rectify errors |
|
|
530
|
+
| `InitiateTransferAction` | Transfer assets between accounts | Transfer assets from one account to another |
|
|
531
|
+
| `OverrideApprovalWorkItemAction` | Override approval work item | Update status with admin decision and comments |
|
|
532
|
+
| `ReassignApprovalWorkItemAction` | Reassign approval work item | Reassign uncompleted work item with comments |
|
|
533
|
+
| `RecallApprovalSubmissionAction` | Recall approval submission | Recall uncompleted submission with comments |
|
|
534
|
+
| `ReviewApprovalWorkItemAction` | Review approval work item | Update status with reviewer decision and comments |
|
|
535
|
+
| `ValidateOrderAction` | Validate order before activation | Validate order before activation |
|
|
536
|
+
| `ValidateQuoteAction` | Validate quote before conversion | Validate quote before conversion |
|
|
537
|
+
|
|
538
|
+
---
|
|
539
|
+
|
|
540
|
+
## Platform Events
|
|
541
|
+
|
|
542
|
+
| Event | Trigger | Key Fields | API Ver |
|
|
543
|
+
| ------------------------------ | ------------------------- | ------------------------------------------------------------------ | ------- |
|
|
544
|
+
| `AssetActionCompletedEvent` | Asset action complete | `AssetId`, `ActionType`, `Status` | - |
|
|
545
|
+
| `CalculatePriceCompletedEvent` | Pricing complete | `TransactionId`, `Status`, `ErrorDetails` | - |
|
|
546
|
+
| `CreateAssetOrderDtlEvent` | Asset creation detail | `AssetId`, `OrderItemId`, `IsSuccess`, `ErrorCode`, `ErrorMessage` | v55.0+ |
|
|
547
|
+
| `CreateAssetOrderEvent` | Asset creation from order | `OrderId`, `AssetIds[]`, `Status` | - |
|
|
548
|
+
| `PlaceOrderCompletedEvent` | Order created/updated | `OrderId`, `Status`, `ErrorCode`, `ErrorMessage` | - |
|
|
549
|
+
| `PlaceQuoteCompletedEvent` | Quote created/updated | `QuoteId`, `Status`, `ErrorCode`, `ErrorMessage` | - |
|
|
550
|
+
| `QuoteSaveEvent` | Quote save complete | `QuoteId`, `Status`, `ErrorCode` | - |
|
|
551
|
+
| `QuoteToOrderCompletedEvent` | Quote→Order conversion | `OrderId`, `QuoteId`, `Status` | - |
|
|
552
|
+
| `SubmitOrderCompletedEvent` | Order submitted | `OrderId`, `SubmissionStatus`, `ErrorDetails` | - |
|
|
553
|
+
|
|
554
|
+
### CreateAssetOrderDtlEvent Details
|
|
555
|
+
|
|
556
|
+
Contains information about asset create/update from
|
|
557
|
+
`/actions/standard/createOrUpdateAssetFromOrder`.
|
|
558
|
+
|
|
559
|
+
**Important:** Included in `CreateAssetOrderEvent` message; cannot subscribe
|
|
560
|
+
directly.
|
|
561
|
+
|
|
562
|
+
**Fields:** | Field | Type | Description | |-------|------|-------------| |
|
|
563
|
+
`AssetId` | Reference | Created/updated asset ID (nillable) | | `ErrorCode` |
|
|
564
|
+
String | Error type reference code (nillable) | | `ErrorMessage` | String |
|
|
565
|
+
Error information (nillable) | | `EventUuid` | String | Platform event message
|
|
566
|
+
UUID (nillable) | | `IsSuccess` | Boolean | Request success status (default:
|
|
567
|
+
false, v61.0+) | | `OrderItemId` | Reference | Order item ID used in request
|
|
568
|
+
(v61.0+) | | `ReplayId` | String | Event stream position (nillable) |
|
|
569
|
+
|
|
570
|
+
**Supported Subscribers:** Apex Triggers, Flows, Processes, Pub/Sub API,
|
|
571
|
+
Streaming API (CometD)
|
|
572
|
+
|
|
573
|
+
**Channel:** `/event/CreateAssetOrderDtlEvent`
|
|
574
|
+
|
|
575
|
+
**Trigger Example:**
|
|
576
|
+
|
|
577
|
+
```apex
|
|
578
|
+
trigger OrderCompletedHandler on PlaceOrderCompletedEvent__e (after insert) {
|
|
579
|
+
for (PlaceOrderCompletedEvent__e evt : Trigger.New) {
|
|
580
|
+
if (evt.Status__c == 'SUCCESS') { /* Handle success */ }
|
|
581
|
+
else if (evt.ErrorCode__c != null) { /* Log error */ }
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
---
|
|
587
|
+
|
|
588
|
+
## Flow Metadata API
|
|
589
|
+
|
|
590
|
+
### Flow Types
|
|
591
|
+
|
|
592
|
+
| FlowType | Purpose |
|
|
593
|
+
| -------------------------- | -------------------------------- |
|
|
594
|
+
| `Pricing` | Custom pricing logic |
|
|
595
|
+
| `ProductConfiguration` | Product configuration rules |
|
|
596
|
+
| `TransactionOrchestration` | Multi-step transaction workflows |
|
|
597
|
+
|
|
598
|
+
### Flow Trigger Types
|
|
599
|
+
|
|
600
|
+
| Trigger | Description |
|
|
601
|
+
| -------------------------- | ------------------------ |
|
|
602
|
+
| `PricingAfterCalculation` | After price calculation |
|
|
603
|
+
| `PricingBeforeCalculation` | Before price calculation |
|
|
604
|
+
| `TransactionAfterSave` | After quote/order save |
|
|
605
|
+
| `TransactionBeforeSave` | Before quote/order save |
|
|
606
|
+
|
|
607
|
+
---
|
|
608
|
+
|
|
609
|
+
## Setup & Configuration
|
|
610
|
+
|
|
611
|
+
### Prerequisites
|
|
612
|
+
|
|
613
|
+
- Enterprise/Unlimited/Developer Edition
|
|
614
|
+
- Lightning Experience enabled
|
|
615
|
+
- Revenue Cloud or Subscription Management license
|
|
616
|
+
- System Administrator or Customize Application permission
|
|
617
|
+
|
|
618
|
+
### Enable Transaction Management
|
|
619
|
+
|
|
620
|
+
1. Setup → Quick Find → "Revenue Settings"
|
|
621
|
+
2. Enable Transaction Management
|
|
622
|
+
3. Configure Transaction Processing Type via Tooling API
|
|
623
|
+
4. Set default processing type in Revenue Settings
|
|
624
|
+
|
|
625
|
+
### Permission Sets
|
|
626
|
+
|
|
627
|
+
| Permission Set | Access |
|
|
628
|
+
| -------------------------- | ----------------------------- |
|
|
629
|
+
| Amend Assets | Asset amendments |
|
|
630
|
+
| Cancel Assets | Asset cancellations |
|
|
631
|
+
| CreateContract API | Contract creation |
|
|
632
|
+
| Customize Application | Feature configuration |
|
|
633
|
+
| Renew Assets | Asset renewals |
|
|
634
|
+
| Sales Rep Permission Group | Create/manage quotes & orders |
|
|
635
|
+
|
|
636
|
+
### Transaction Processing Type (Tooling API)
|
|
637
|
+
|
|
638
|
+
```json
|
|
639
|
+
// POST /tooling/sobjects/TransactionProcessingType/
|
|
640
|
+
{
|
|
641
|
+
"DeveloperName": "StandardProcessing",
|
|
642
|
+
"MasterLabel": "Standard Processing",
|
|
643
|
+
"IsActive": true,
|
|
644
|
+
"SkipPricingCalculation": false,
|
|
645
|
+
"SkipTaxCalculation": false,
|
|
646
|
+
"UseAdvancedConfigurator": true
|
|
647
|
+
}
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
---
|
|
651
|
+
|
|
652
|
+
## Integration Patterns
|
|
653
|
+
|
|
654
|
+
### Flow Diagrams
|
|
655
|
+
|
|
656
|
+
```
|
|
657
|
+
E-commerce: Storefront → REST API → PlaceSalesTransaction → Order → Platform Events → Fulfillment
|
|
658
|
+
ERP Sync: ERP ↔ REST API ↔ PlaceSalesTransaction/ReadSalesTransaction (Scheduled Apex | Platform Events)
|
|
659
|
+
CPQ: CPQ → PlaceQuote → CalculatePrice → PlaceSalesTransaction (Order)
|
|
660
|
+
Tax Engine: Transaction Management → CommerceTax namespace → External Tax Engine
|
|
661
|
+
Ramp Deal: Quote/Order → CreateRampDeal → UpdateRampDeal → ViewRampDeal → DeleteRampDeal
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
### Idempotency Pattern
|
|
665
|
+
|
|
666
|
+
```apex
|
|
667
|
+
public static RevSalesTrxn.PlaceSalesTransactionResponse placeTransactionWithIdempotency(
|
|
668
|
+
RevSalesTrxn.PlaceSalesTransactionRequest req, String externalId) {
|
|
669
|
+
List<Quote> existing = [SELECT Id FROM Quote WHERE ExternalId__c = :externalId LIMIT 1];
|
|
670
|
+
if (!existing.isEmpty()) {
|
|
671
|
+
RevSalesTrxn.PlaceSalesTransactionResponse resp = new RevSalesTrxn.PlaceSalesTransactionResponse();
|
|
672
|
+
resp.success = true;
|
|
673
|
+
resp.salesTransactionId = existing[0].Id;
|
|
674
|
+
return resp;
|
|
675
|
+
}
|
|
676
|
+
return RevSalesTrxn.placeSalesTransaction(req);
|
|
677
|
+
}
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
### Circuit Breaker Pattern
|
|
681
|
+
|
|
682
|
+
```apex
|
|
683
|
+
public class CircuitBreaker {
|
|
684
|
+
private static Map<String, CircuitState> states = new Map<String, CircuitState>();
|
|
685
|
+
private static final Integer FAILURE_THRESHOLD = 5;
|
|
686
|
+
private static final Integer TIMEOUT_SECONDS = 60;
|
|
687
|
+
|
|
688
|
+
public static Boolean isOpen(String serviceName) {
|
|
689
|
+
CircuitState state = states.get(serviceName);
|
|
690
|
+
if (state == null) { state = new CircuitState(); states.put(serviceName, state); }
|
|
691
|
+
if (state.status == 'OPEN' && DateTime.now().getTime() - state.lastFailureTime > TIMEOUT_SECONDS * 1000) {
|
|
692
|
+
state.status = 'HALF_OPEN'; state.failureCount = 0;
|
|
693
|
+
}
|
|
694
|
+
return state.status == 'OPEN';
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
public static void recordSuccess(String serviceName) {
|
|
698
|
+
CircuitState state = states.get(serviceName);
|
|
699
|
+
if (state != null) { state.status = 'CLOSED'; state.failureCount = 0; }
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
public static void recordFailure(String serviceName) {
|
|
703
|
+
CircuitState state = states.get(serviceName);
|
|
704
|
+
if (state == null) { state = new CircuitState(); states.put(serviceName, state); }
|
|
705
|
+
state.failureCount++;
|
|
706
|
+
state.lastFailureTime = DateTime.now().getTime();
|
|
707
|
+
if (state.failureCount >= FAILURE_THRESHOLD) state.status = 'OPEN';
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
private class CircuitState { String status = 'CLOSED'; Integer failureCount = 0; Long lastFailureTime = 0; }
|
|
711
|
+
}
|
|
712
|
+
```
|
|
713
|
+
|
|
714
|
+
### Best Practices
|
|
715
|
+
|
|
716
|
+
1. Handle partial failures in bulk operations
|
|
717
|
+
2. Implement idempotency for duplicate request handling
|
|
718
|
+
3. Implement proper error logging and alerting
|
|
719
|
+
4. Implement retry logic with exponential backoff
|
|
720
|
+
5. Monitor API usage and governor limits
|
|
721
|
+
6. Test in sandbox before production
|
|
722
|
+
7. Use bulk operations where possible
|
|
723
|
+
8. Use context IDs to maintain transaction state
|
|
724
|
+
9. Use OAuth for secure API authentication
|
|
725
|
+
10. Use Platform Events for decoupled real-time communication
|
|
726
|
+
11. Use standard APIs over custom integrations
|
|
727
|
+
12. Validate input data before API calls
|
|
728
|
+
|
|
729
|
+
---
|
|
730
|
+
|
|
731
|
+
## Common Patterns
|
|
732
|
+
|
|
733
|
+
### Create Quote with Line Items
|
|
734
|
+
|
|
735
|
+
```apex
|
|
736
|
+
RevSalesTrxn.PlaceSalesTransactionRequest req = new RevSalesTrxn.PlaceSalesTransactionRequest();
|
|
737
|
+
req.transactionType = 'NewQuote';
|
|
738
|
+
req.records = new Map<String, List<Map<String, Object>>>{
|
|
739
|
+
'Quote' => new List<Map<String, Object>>{
|
|
740
|
+
new Map<String, Object>{'OpportunityId' => oppId, 'Pricebook2Id' => pricebookId, 'Name' => 'Quote-001'}
|
|
741
|
+
},
|
|
742
|
+
'QuoteLineItem' => new List<Map<String, Object>>{
|
|
743
|
+
new Map<String, Object>{'Product2Id' => productId, 'Quantity' => 10, 'UnitPrice' => 100.00}
|
|
744
|
+
}
|
|
745
|
+
};
|
|
746
|
+
RevSalesTrxn.PlaceSalesTransactionResponse resp = RevSalesTrxn.placeSalesTransaction(req);
|
|
747
|
+
```
|
|
748
|
+
|
|
749
|
+
### Convert Quote to Order
|
|
750
|
+
|
|
751
|
+
```apex
|
|
752
|
+
Invocable.Action.CreateOrderFromQuoteAction action = new Invocable.Action.CreateOrderFromQuoteAction();
|
|
753
|
+
action.quoteId = quoteId;
|
|
754
|
+
action.activateOrder = false;
|
|
755
|
+
List<Invocable.Action.Result> results = action.invoke();
|
|
756
|
+
```
|
|
757
|
+
|
|
758
|
+
### Asset Amendment Flow
|
|
759
|
+
|
|
760
|
+
```apex
|
|
761
|
+
// 1. Initiate amendment
|
|
762
|
+
RevSalesTrxn.InitiateAmendmentRequest req = new RevSalesTrxn.InitiateAmendmentRequest();
|
|
763
|
+
req.assetIds = new List<Id>{assetId};
|
|
764
|
+
req.amendmentDate = Date.today();
|
|
765
|
+
RevSalesTrxn.InitiateAmendmentResponse resp = RevSalesTrxn.initiateAmendment(req);
|
|
766
|
+
|
|
767
|
+
// 2. Modify generated quote (resp.quoteId)
|
|
768
|
+
// 3. Convert to order via CreateOrderFromQuoteAction
|
|
769
|
+
// 4. Asset updated automatically on order activation
|
|
770
|
+
```
|
|
771
|
+
|
|
772
|
+
### Context Reuse
|
|
773
|
+
|
|
774
|
+
```apex
|
|
775
|
+
String contextId = null;
|
|
776
|
+
RevSalesTrxn.PlaceSalesTransactionResponse resp1 = RevSalesTrxn.placeSalesTransaction(req1);
|
|
777
|
+
contextId = resp1.contextId;
|
|
778
|
+
|
|
779
|
+
RevSalesTrxn.PlaceSalesTransactionRequest req2 = new RevSalesTrxn.PlaceSalesTransactionRequest();
|
|
780
|
+
req2.contextId = contextId; // Reuse context
|
|
781
|
+
RevSalesTrxn.PlaceSalesTransactionResponse resp2 = RevSalesTrxn.placeSalesTransaction(req2);
|
|
782
|
+
```
|
|
783
|
+
|
|
784
|
+
---
|
|
785
|
+
|
|
786
|
+
## Troubleshooting
|
|
787
|
+
|
|
788
|
+
| Issue | Cause | Solution |
|
|
789
|
+
| -------------------------------------- | ------------------------------ | -------------------------------------- |
|
|
790
|
+
| Asset amendment fails | Missing permissions | Assign "Amend Assets" permission set |
|
|
791
|
+
| `CalculationStatus` stuck `InProgress` | Long-running pricing procedure | Check pricing logs, retry calculation |
|
|
792
|
+
| Context expired | Context lifetime exceeded | Create new context |
|
|
793
|
+
| Platform event not firing | Not subscribed | Verify trigger/subscription exists |
|
|
794
|
+
| Pricing returns zero | Missing price book entry | Verify PricebookEntry exists |
|
|
795
|
+
| Quote conversion fails | Validation rules | Review validation rules on Quote/Order |
|
|
796
|
+
|
|
797
|
+
### Debug Checklist
|
|
798
|
+
|
|
799
|
+
1. Check user permissions (permission sets assigned)
|
|
800
|
+
2. Verify object/field accessibility (FLS)
|
|
801
|
+
3. Review validation rules
|
|
802
|
+
4. Check governor limits (debug logs)
|
|
803
|
+
5. Verify API version compatibility
|
|
804
|
+
6. Check for record locks
|
|
805
|
+
7. Review error details in response
|
|
806
|
+
|
|
807
|
+
---
|
|
808
|
+
|
|
809
|
+
## Testing Patterns
|
|
810
|
+
|
|
811
|
+
### Test Setup
|
|
812
|
+
|
|
813
|
+
```apex
|
|
814
|
+
@IsTest
|
|
815
|
+
private class TransactionManagementTest {
|
|
816
|
+
@TestSetup
|
|
817
|
+
static void setup() {
|
|
818
|
+
Account acc = new Account(Name = 'Test Account');
|
|
819
|
+
insert acc;
|
|
820
|
+
Opportunity opp = new Opportunity(Name = 'Test Opp', AccountId = acc.Id, StageName = 'Prospecting', CloseDate = Date.today().addDays(30));
|
|
821
|
+
insert opp;
|
|
822
|
+
Product2 prod = new Product2(Name = 'Test Product', IsActive = true);
|
|
823
|
+
insert prod;
|
|
824
|
+
Pricebook2 pb = [SELECT Id FROM Pricebook2 WHERE IsStandard = true LIMIT 1];
|
|
825
|
+
PricebookEntry pbe = new PricebookEntry(Pricebook2Id = pb.Id, Product2Id = prod.Id, UnitPrice = 100.00, IsActive = true);
|
|
826
|
+
insert pbe;
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
```
|
|
830
|
+
|
|
831
|
+
### Test Best Practices
|
|
832
|
+
|
|
833
|
+
- Mock external callouts when needed
|
|
834
|
+
- Test async operations with proper wait mechanisms
|
|
835
|
+
- Test both success and error scenarios
|
|
836
|
+
- Test bulk operations (200+ records)
|
|
837
|
+
- Test governor limit scenarios
|
|
838
|
+
- Use `@TestSetup` for common test data
|
|
839
|
+
- Use `Test.startTest()` / `Test.stopTest()` to reset limits
|
|
840
|
+
- Verify response structure and field values
|
|
841
|
+
|
|
842
|
+
---
|
|
843
|
+
|
|
844
|
+
## Glossary
|
|
845
|
+
|
|
846
|
+
| Term | Definition |
|
|
847
|
+
| --------------------------- | --------------------------------------------------------------------------------------- |
|
|
848
|
+
| Asset | Product/service delivered to customer, tracks ownership and lifecycle |
|
|
849
|
+
| Asset Action | Change made to lifecycle-managed asset (amend, cancel, renew, transfer) |
|
|
850
|
+
| Asset State Period | Time span when asset has same quantity, amount, and MRR |
|
|
851
|
+
| Calculation Status | Status of price and tax calculations for quotes/orders |
|
|
852
|
+
| Context | Session identifier for reusing transaction state across API calls |
|
|
853
|
+
| Contract | Formal agreement for managing assets, products, and services with pricing schedules |
|
|
854
|
+
| Order | Confirmed request for products/services, represents formal agreement |
|
|
855
|
+
| Order Item Group | Groups related order items for fulfillment organization |
|
|
856
|
+
| Platform Event | Real-time messaging mechanism for event-driven architectures |
|
|
857
|
+
| Pricing Procedure | Set of rules and steps used to calculate prices for products |
|
|
858
|
+
| Quote | Preliminary offer of products/services with pricing, can be revised before conversion |
|
|
859
|
+
| Quote Line Group | Groups related quote line items with subtotal calculations |
|
|
860
|
+
| Ramp Deal | Multi-segment pricing deal with different attributes per segment over subscription term |
|
|
861
|
+
| Supplemental Transaction | Additional order or change order created after original order submission |
|
|
862
|
+
| Transaction Processing Type | Configuration that defines how quotes/orders are processed |
|
|
863
|
+
|
|
864
|
+
---
|
|
865
|
+
|
|
866
|
+
## Reference Links
|
|
867
|
+
|
|
868
|
+
| Resource | URL |
|
|
869
|
+
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
870
|
+
| Apex Reference | [Apex Namespaces](https://developer.salesforce.com/docs/atlas.en-us.revenue_lifecycle_management_dev_guide.meta/revenue_lifecycle_management_dev_guide/qoc_apex_reference.htm) |
|
|
871
|
+
| API Requests | [Input Structures](https://developer.salesforce.com/docs/atlas.en-us.revenue_lifecycle_management_dev_guide.meta/revenue_lifecycle_management_dev_guide/qoc_api_requests.htm) |
|
|
872
|
+
| API Responses | [Output Structures](https://developer.salesforce.com/docs/atlas.en-us.revenue_lifecycle_management_dev_guide.meta/revenue_lifecycle_management_dev_guide/qoc_api_responses.htm) |
|
|
873
|
+
| Asset Data Model | [ERD](https://developer.salesforce.com/docs/platform/data-models/guide/transaction-management-asset.html) |
|
|
874
|
+
| Business APIs | [API Reference](https://developer.salesforce.com/docs/atlas.en-us.revenue_lifecycle_management_dev_guide.meta/revenue_lifecycle_management_dev_guide/qoc_business_apis.htm) |
|
|
875
|
+
| Contract Data Model | [ERD](https://developer.salesforce.com/docs/platform/data-models/guide/transaction-management-contract.html) |
|
|
876
|
+
| Fields Reference | [Standard Object Fields](https://developer.salesforce.com/docs/atlas.en-us.revenue_lifecycle_management_dev_guide.meta/revenue_lifecycle_management_dev_guide/quote_and_order_capture_fields_on_standard_objects.htm) |
|
|
877
|
+
| Flow Metadata API | [Flow Reference](https://developer.salesforce.com/docs/atlas.en-us.revenue_lifecycle_management_dev_guide.meta/revenue_lifecycle_management_dev_guide/qoc_flow_metadata_api.htm) |
|
|
878
|
+
| Invocable Actions | [Actions Reference](https://developer.salesforce.com/docs/atlas.en-us.revenue_lifecycle_management_dev_guide.meta/revenue_lifecycle_management_dev_guide/qoc_invocable_actions_parent.htm) |
|
|
879
|
+
| Metadata API Guide | [Understanding Metadata API](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_intro.htm) |
|
|
880
|
+
| Metadata API Types | [Metadata Reference](https://developer.salesforce.com/docs/atlas.en-us.revenue_lifecycle_management_dev_guide.meta/revenue_lifecycle_management_dev_guide/qoc_metadata_api_parent.htm) |
|
|
881
|
+
| Order Data Model | [ERD](https://developer.salesforce.com/docs/platform/data-models/guide/transaction-mgmt-order.html) |
|
|
882
|
+
| Platform Events | [Events Reference](https://developer.salesforce.com/docs/atlas.en-us.revenue_lifecycle_management_dev_guide.meta/revenue_lifecycle_management_dev_guide/quote_and_order_capture_platform_event.htm) |
|
|
883
|
+
| Quote Data Model | [ERD](https://developer.salesforce.com/docs/platform/data-models/guide/transaction-management-quote.html) |
|
|
884
|
+
| REST API Reference | [REST Endpoints](https://developer.salesforce.com/docs/atlas.en-us.revenue_lifecycle_management_dev_guide.meta/revenue_lifecycle_management_dev_guide/qoc_business_apis_rest_references.htm) |
|
|
885
|
+
| Standard Objects | [Object Reference](https://developer.salesforce.com/docs/atlas.en-us.revenue_lifecycle_management_dev_guide.meta/revenue_lifecycle_management_dev_guide/quote_and_order_capture_standard_objects.htm) |
|
|
886
|
+
| Transaction Management Overview | [Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.revenue_lifecycle_management_dev_guide.meta/revenue_lifecycle_management_dev_guide/qoc_overview.htm) |
|
|
887
|
+
| TransactionProcessingType | [Tooling API](https://developer.salesforce.com/docs/atlas.en-us.revenue_lifecycle_management_dev_guide.meta/revenue_lifecycle_management_dev_guide/tooling_api_objects_transactionprocessingtype.htm) |
|