When writing Apex unit tests that simulate an Amendment action using direct DML — such as manually updating a QuoteLineItem quantity — QuoteLineDetail records are not generated. The same scenario executed through the Revenue Cloud UI produces QuoteLineDetail records as expected. This discrepancy causes test coverage failures for triggers on the QuoteLineDetail object and can prevent deployment to UAT or Production.
This behavior is by design. Revenue Cloud's QuoteLineDetail generation logic executes at the UI and Rev Cloud API layer, not at the database DML layer. QuoteLineDetail records are created as a platform-managed side effect of specific Revenue Cloud transactions, including:
- Reconfigured bundles
- Early renewals
- Amendment quantity reductions
Bypassing the API by performing amendment quantity changes through direct DML skips the internal logic responsible for creating these records. No QuoteLineDetail records are generated as a result, regardless of the data state.
Use the Revenue Cloud invocable "initiateAmendment" API inside the Apex test class instead of direct DML. This triggers the same platform logic that runs during a real transaction and causes QuoteLineDetail records to be generated in the test context.
-------------------------------------------------------------------------------------------
@IsTest(SeeAllData=true)
public class QuoteLineDetailCreationTest {
@IsTest
public static void testQuoteLineDetails() {
Test.startTest();
Invocable.Action action = Invocable.Action.createStandardAction('initiateAmendment');
action.setInvocationParameter('amendAssetIds', new List<String>{'02iHn00000L4BTgIAN'});
action.setInvocationParameter('amendStartDate', '2025-10-09T00:00:00.000Z');
action.setInvocationParameter('quantityChange', -1);
action.setInvocationParameter('amendOutputType', 'Quote');
action.setInvocationParameter('skipPricing', false);
List<Invocable.Action.Result> results = action.invoke();
System.debug(JSON.serializePretty(results));
List<QuoteLineDetail> qlds = [SELECT Id FROM QuoteLineDetail
WHERE QuoteLineItem.QuoteAction.SourceAssetId = '02iHn00000L4BTgIAN'];
System.debug('QuoteLineDetail records created: ' + JSON.serializePretty(qlds));
Test.stopTest();
}
}
-------------------------------------------------------------------------------------------
This test class calls the standard `initiateAmendment` invocable action with a quantity reduction of -1 against a specified Asset. After invocation, it queries QuoteLineDetail records linked to the source Asset to confirm they were generated. Replace `02iHn00000L4BTgIAN` with the ID of a valid, pre-existing Asset record in your org. Because this approach requires an existing Asset, the test uses `SeeAllData=true` to access real org data.
1. Identify a valid Asset record ID in your org to use as the amendment target.
2. Create a new Apex test class and annotate it with `@IsTest(SeeAllData=true)`.
3. Inside the test method, call `Invocable.Action.createStandardAction('initiateAmendment')`.
4. Set the required invocation parameters: `amendAssetIds`, `amendStartDate`, `quantityChange`, `amendOutputType`, and `skipPricing`.
5. Replace the hardcoded Asset ID `02iHn00000L4BTgIAN` with the valid Asset ID from step 1.
6. Call `action.invoke()` within `Test.startTest()` and `Test.stopTest()` boundaries.
7. Query QuoteLineDetail records filtered by the source Asset ID to verify records were created.
8. Add any trigger coverage assertions against the returned QuoteLineDetail records as needed.
005391236

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.