I`m trying to call Continuation method from Apex that has

@AuraEnabled(continuation=true cacheable=true)

but getting next error:

Apex methods for continuation can not be invoked from a non-continuation action.

Here is the .js code that calls Apex:

    proceedToBillingData() {
//unnecessary code skipped
    getCart({ paymentData: JSON.stringify(this.pricingOption) })
                .then(cartResult => {
                    this.isCartAvailable = true;
                    this.cartEncryptedId = cartResult.cartEncId;
                    return getTotalNetPriceFromSAP({ cartEncId: cartResult.cartEncId });
                .then(sapResult => {
                    //TODO: obtain result from SAP
                    this.totalPrice = this.userFormatter.format(sapResult['ccrz__Price__c']);
                    this.vat = ((sapResult['ccrz__Price__c'] - this.pricingOption.exclVATPrice) / sapResult['ccrz__Price__c']) * 100;
                    this.isLoading = false;
                .catch(error => {
                    console.error('error --- ', error);
                    this.isLoading = false;
                    this.isError   = true;
                    this.errors    = error.body.message;

getTotalNetPriceFromSAP() - is Continuation method

Apex code:

@AuraEnabled(continuation=true cacheable=true)
    public static Map<String, Object> getTotalNetPriceFromSAP(final String cartEncId) {
        //TODO: replace the code below with results from SAP callout using Continuation
        List<ccrz__E_Cart__c> openCart = [SELECT ccrz__Account__r.SAP_Customer_Number__c,
                                                (SELECT ccrz__Quantity__c FROM ccrz__E_CartItems__r)
                                          FROM ccrz__E_Cart__c WHERE ccrz__EncryptedId__c = :cartEncId];
        if (openCart[0].ccrz__E_CartItems__r.isEmpty()) {
            throw CustomException.setErrorMessage(String.format(CustomException.NO_CART_ITEMS_BY_USER_ID, new String[] { currentUser.Id }));
        try {
            Continuation continuation = (Continuation) CC_EpayVatSimulate.startOrderSimulate(openCart[0]);
            System.debug('getTotalNetPriceFromSAP --- ' + continuation);
            return new Map<String, Object> { SObjectType.ccrz__E_CartItem__c.fields.ccrz__Price__c.Name => openCart[0].ccrz__E_CartItems__r[0].ccrz__Price__c };
        } catch (Exception e) {

The method is not being executed because of that error. If I remove the annotation params

(continuation=true cacheable=true)

it works, the method, not Continuation.

What could be the reason of this? Is the lwc action must be @wire only and not on-demand bcoz there is cacheable=true param?


The issue was in lwc import.

import getTotalNetPriceFromSAP from '@salesforce/apex/SFMS_SubscriptionsOverviewController.getTotalNetPriceFromSAP';

But for Continuation it must be:

import getTotalNetPriceFromSAP from '@salesforce/apexContinuation/SFMS_SubscriptionsOverviewController.getTotalNetPriceFromSAP';



This question is closed.


Your method ** getTotalNetPriceFromSAP** does not return continuation.

Understanding continuation: Apex method sends request to external system and forgets about it (it does not wait for response). In below method, startRequest returns continuation. Observe con.continuationMethod='processResponse'. This means whenever the response is returned, method processResponse is invoked.

@AuraEnabled(continuation=true cacheable=true)
public static Object startRequest() {
    Continuation con = new Continuation(40);
    HttpRequest req = new HttpRequest();
    con.state = con.addHttpRequest(req);
    return con;  

processResponse method:

public static Object processResponse(Object state) {
    HttpResponse response = Continuation.getResponse((String)state);
    return response.getBody();

Note: timeout mentioned while initialising continuation is stored by continuation server, not apex method and hence I said it forgets the request.

  • thanks for the investigation. I have processResponse() method, just did not add it to the question as the question itself relates to another issue. – m_konyk Jul 17 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.