Loading
Slack 관련 문의처가 Salesforce Help로 통합 및 변경됩니다.더 많이 읽기

Revenue Cloud: QuoteLineDetail Records Not Created in Apex Test Classes Using Direct DML During Amendment

게시 일자: Aug 20, 2026
상세 설명

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.

Knowledge 기사 번호

005391236

 
로드 중
Salesforce Help | Article