• Vineet Goel
  • NEWBIE
  • 0 Points
  • Member since 2016
  • Self


  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
The actual code is very big, I tried to simplify it as much as possible.
The design is such we cannot call the continuation method directly. So looking for ways of invoking it.
VF page

VF page

Controller:

controller


Is it True , Continuation callback is invoked only when a continuation is initialized from Visualforce only. It will not work if continuation is initiated by any Apex.If yes, then how can we use Continuation in this scenario. Many Thanks
Component:
<aura:component controller="RemovefromDNCcontroller"
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickActionWithoutHeader" access="global">
    <ltng:require styles="{!$Resource.quickActionStyle}"/>
    <aura:attribute name="recordId" type="Id" />
    <aura:attribute name="Preval" type="RemovefromDNCcontroller" />
    <aura:attribute name="Preaccount" type="Id"/>
    <aura:attribute name="Precontact" type="Id"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:if isTrue = "{!v.Preval.messageDisplay}">
        <div class="slds-notify slds-notify_alert slds-theme_alert-texture slds-theme_info" role="alert">
            {!v.Preval.message}
        </div>
    </aura:if>
</aura:component>

Controller.js

({
    doInit : function(component, event,helper) {
        var action = component.get("c.Oppdetails");
        action.setParams({"OppId": component.get("v.recordId")});
        action.setCallback(this, function(response) {
            var responsedata = response.getReturnValue();
            var accid = response.getReturnValue().caseaccId;
            var conid = response.getReturnValue().caseContactId;
            var state = response.getState();
            console.log('accid==='+accid);
            console.log('conid==='+conid);
            helper.fetchAccdetail(component,event,helper,accid);
            helper.fetchCondetails(component, event, helper,conid);
            if (component.isValid() && state === "SUCCESS") {
                component.set("v.Preval", response.getReturnValue());
                helper.createCasDetails(component,event,helper,responsedata);
            }
        });
        $A.enqueueAction(action);
    },
})

Helper.js
({
    fetchAccdetail : function(component, event, helper,accid) {
        console.log('accid helper==='+accid);
        var action = component.get("c.accountPreCheck");
        action.setParams({
            "AccountcheckId" : accid
        });
        
        action.setCallback(this, function(response){
            var state = response.getState();
            console.log('response acc===='+response.getReturnValue());            
            if (state === "SUCCESS") {
                component.set("v.Preaccount", response.getReturnValue());
                //var Acc = component.get("v.Preaccount");
                //console.log("Acc---"+Acc);
            }
        });
        $A.enqueueAction(action);
    },
    fetchCondetails : function(component, event, helper,conid) {
        console.log('conid helper==='+conid);
        var action = component.get("c.contactPreCheck");
        action.setParams({
            "ContactcheckId" : conid
        });
        
        action.setCallback(this, function(response){
            var state = response.getState();
            console.log('response con==='+response.getReturnValue());            
            if (state === "SUCCESS") {
                component.set("v.Precontact", response.getReturnValue());
                //var con = component.get("v.Precontact");
                //console.log("con---"+con);
            }
        });
        $A.enqueueAction(action);
    },
    createCasDetails: function(component,event,helper,responsedata){
        console.log("responsedata---"+responsedata.messageDisplay);
        if(responsedata.messageDisplay == false){
            var Acc = component.get("v.Preaccount");
            var con = component.get("v.Precontact");
            console.log("Acccase---"+Acc);
            console.log("concase---"+con);
            var createCaseEvent = $A.get("e.force:createRecord");
            createCaseEvent.setParams({
                "entityApiName": "Case",
                "defaultFieldValues": {
                    'Case_Type__c'     : 'Do Not Call List Request',
                    'Account'        : Acc,
                    'Contact'        : con,
                    'Opportunity__c': responsedata.caseOppId
                }
            });
            createCaseEvent.fire();
        }
    },
})

Apex Class:

public with sharing class RemovefromDNCcontroller {

    @AuraEnabled public string caseaccId{get;set;}
    @AuraEnabled public string caseContactId{get;set;}
    @AuraEnabled public string caseOppId{get;set;}
    @AuraEnabled public string message{get;set;}
    @AuraEnabled public boolean messageDisplay{get;set;}
    
    @AuraEnabled 
    public static RemovefromDNCcontroller Oppdetails (Id OppId){
        RemovefromDNCcontroller rfd = new RemovefromDNCcontroller();
         rfd.messageDisplay = false;
        Opportunity o = [select id, Name,ownerId, AccountId, Account.PersonContactId, Do_Not_Call__c from Opportunity where Id =: OppId];
        system.debug('o----'+o);
        if(o.Do_Not_Call__c == true){
            system.debug('rfd 24'+ rfd.message);
            rfd.caseOppId = o.Id;
            rfd.caseContactId = o.Account.PersonContactId;
            rfd.caseaccId = o.AccountId;
            system.debug('caseContactId ==='+rfd.caseContactId);
            system.debug('caseaccId ==='+rfd.caseaccId);
            return rfd;
        }else{
            rfd.message = system.Label.Remove_from_DNC_Alert;
            rfd.messageDisplay = true;
            system.debug('rfd 32'+ rfd.message);
            return rfd;
            
        }
        
    }
    @AuraEnabled 
    public static Id accountPreCheck (Id AccountcheckId){
        system.debug('AccountcheckId--'+AccountcheckId);
        return AccountcheckId;
    }
    @AuraEnabled 
    public static Id contactPreCheck (Id ContactcheckId){
        system.debug('ContactcheckId--'+ContactcheckId);
        return ContactcheckId;
    }
}

In Helper, method createCasDetails, values in 
console.log("Acccase---"+Acc);
console.log("concase---"+con);
are not coming due to which values in Account and Contact are not pre-populating.
Please help.
Component:
<aura:component controller="RemovefromDNCcontroller"
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickActionWithoutHeader" access="global">
    <ltng:require styles="{!$Resource.quickActionStyle}"/>
    <aura:attribute name="recordId" type="Id" />
    <aura:attribute name="Preval" type="RemovefromDNCcontroller" />
    <aura:attribute name="Preaccount" type="Id"/>
    <aura:attribute name="Precontact" type="Id"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:if isTrue = "{!v.Preval.messageDisplay}">
        <div class="slds-notify slds-notify_alert slds-theme_alert-texture slds-theme_info" role="alert">
            {!v.Preval.message}
        </div>
    </aura:if>
</aura:component>

Controller.js

({
    doInit : function(component, event,helper) {
        var action = component.get("c.Oppdetails");
        action.setParams({"OppId": component.get("v.recordId")});
        action.setCallback(this, function(response) {
            var responsedata = response.getReturnValue();
            var accid = response.getReturnValue().caseaccId;
            var conid = response.getReturnValue().caseContactId;
            var state = response.getState();
            console.log('accid==='+accid);
            console.log('conid==='+conid);
            helper.fetchAccdetail(component,event,helper,accid);
            helper.fetchCondetails(component, event, helper,conid);
            if (component.isValid() && state === "SUCCESS") {
                component.set("v.Preval", response.getReturnValue());
                helper.createCasDetails(component,event,helper,responsedata);
            }
        });
        $A.enqueueAction(action);
    },
})

Helper.js
({
    fetchAccdetail : function(component, event, helper,accid) {
        console.log('accid helper==='+accid);
        var action = component.get("c.accountPreCheck");
        action.setParams({
            "AccountcheckId" : accid
        });
        
        action.setCallback(this, function(response){
            var state = response.getState();
            console.log('response acc===='+response.getReturnValue());            
            if (state === "SUCCESS") {
                component.set("v.Preaccount", response.getReturnValue());
                //var Acc = component.get("v.Preaccount");
                //console.log("Acc---"+Acc);
            }
        });
        $A.enqueueAction(action);
    },
    fetchCondetails : function(component, event, helper,conid) {
        console.log('conid helper==='+conid);
        var action = component.get("c.contactPreCheck");
        action.setParams({
            "ContactcheckId" : conid
        });
        
        action.setCallback(this, function(response){
            var state = response.getState();
            console.log('response con==='+response.getReturnValue());            
            if (state === "SUCCESS") {
                component.set("v.Precontact", response.getReturnValue());
                //var con = component.get("v.Precontact");
                //console.log("con---"+con);
            }
        });
        $A.enqueueAction(action);
    },
    createCasDetails: function(component,event,helper,responsedata){
        console.log("responsedata---"+responsedata.messageDisplay);
        if(responsedata.messageDisplay == false){
            var Acc = component.get("v.Preaccount");
            var con = component.get("v.Precontact");
            console.log("Acccase---"+Acc);
            console.log("concase---"+con);
            var createCaseEvent = $A.get("e.force:createRecord");
            createCaseEvent.setParams({
                "entityApiName": "Case",
                "defaultFieldValues": {
                    'Case_Type__c'     : 'Do Not Call List Request',
                    'Account'        : Acc,
                    'Contact'        : con,
                    'Opportunity__c': responsedata.caseOppId
                }
            });
            createCaseEvent.fire();
        }
    },
})

Apex Class:

public with sharing class RemovefromDNCcontroller {

    @AuraEnabled public string caseaccId{get;set;}
    @AuraEnabled public string caseContactId{get;set;}
    @AuraEnabled public string caseOppId{get;set;}
    @AuraEnabled public string message{get;set;}
    @AuraEnabled public boolean messageDisplay{get;set;}
    
    @AuraEnabled 
    public static RemovefromDNCcontroller Oppdetails (Id OppId){
        RemovefromDNCcontroller rfd = new RemovefromDNCcontroller();
         rfd.messageDisplay = false;
        Opportunity o = [select id, Name,ownerId, AccountId, Account.PersonContactId, Do_Not_Call__c from Opportunity where Id =: OppId];
        system.debug('o----'+o);
        if(o.Do_Not_Call__c == true){
            system.debug('rfd 24'+ rfd.message);
            rfd.caseOppId = o.Id;
            rfd.caseContactId = o.Account.PersonContactId;
            rfd.caseaccId = o.AccountId;
            system.debug('caseContactId ==='+rfd.caseContactId);
            system.debug('caseaccId ==='+rfd.caseaccId);
            return rfd;
        }else{
            rfd.message = system.Label.Remove_from_DNC_Alert;
            rfd.messageDisplay = true;
            system.debug('rfd 32'+ rfd.message);
            return rfd;
            
        }
        
    }
    @AuraEnabled 
    public static Id accountPreCheck (Id AccountcheckId){
        system.debug('AccountcheckId--'+AccountcheckId);
        return AccountcheckId;
    }
    @AuraEnabled 
    public static Id contactPreCheck (Id ContactcheckId){
        system.debug('ContactcheckId--'+ContactcheckId);
        return ContactcheckId;
    }
}

In Helper, method createCasDetails, values in 
console.log("Acccase---"+Acc);
console.log("concase---"+con);
are not coming due to which values in Account and Contact are not pre-populating.
Please help.
The actual code is very big, I tried to simplify it as much as possible.
The design is such we cannot call the continuation method directly. So looking for ways of invoking it.
VF page

VF page

Controller:

controller


Is it True , Continuation callback is invoked only when a continuation is initialized from Visualforce only. It will not work if continuation is initiated by any Apex.If yes, then how can we use Continuation in this scenario. Many Thanks
Component:
<aura:component controller="RemovefromDNCcontroller"
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickActionWithoutHeader" access="global">
    <ltng:require styles="{!$Resource.quickActionStyle}"/>
    <aura:attribute name="recordId" type="Id" />
    <aura:attribute name="Preval" type="RemovefromDNCcontroller" />
    <aura:attribute name="Preaccount" type="Id"/>
    <aura:attribute name="Precontact" type="Id"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:if isTrue = "{!v.Preval.messageDisplay}">
        <div class="slds-notify slds-notify_alert slds-theme_alert-texture slds-theme_info" role="alert">
            {!v.Preval.message}
        </div>
    </aura:if>
</aura:component>

Controller.js

({
    doInit : function(component, event,helper) {
        var action = component.get("c.Oppdetails");
        action.setParams({"OppId": component.get("v.recordId")});
        action.setCallback(this, function(response) {
            var responsedata = response.getReturnValue();
            var accid = response.getReturnValue().caseaccId;
            var conid = response.getReturnValue().caseContactId;
            var state = response.getState();
            console.log('accid==='+accid);
            console.log('conid==='+conid);
            helper.fetchAccdetail(component,event,helper,accid);
            helper.fetchCondetails(component, event, helper,conid);
            if (component.isValid() && state === "SUCCESS") {
                component.set("v.Preval", response.getReturnValue());
                helper.createCasDetails(component,event,helper,responsedata);
            }
        });
        $A.enqueueAction(action);
    },
})

Helper.js
({
    fetchAccdetail : function(component, event, helper,accid) {
        console.log('accid helper==='+accid);
        var action = component.get("c.accountPreCheck");
        action.setParams({
            "AccountcheckId" : accid
        });
        
        action.setCallback(this, function(response){
            var state = response.getState();
            console.log('response acc===='+response.getReturnValue());            
            if (state === "SUCCESS") {
                component.set("v.Preaccount", response.getReturnValue());
                //var Acc = component.get("v.Preaccount");
                //console.log("Acc---"+Acc);
            }
        });
        $A.enqueueAction(action);
    },
    fetchCondetails : function(component, event, helper,conid) {
        console.log('conid helper==='+conid);
        var action = component.get("c.contactPreCheck");
        action.setParams({
            "ContactcheckId" : conid
        });
        
        action.setCallback(this, function(response){
            var state = response.getState();
            console.log('response con==='+response.getReturnValue());            
            if (state === "SUCCESS") {
                component.set("v.Precontact", response.getReturnValue());
                //var con = component.get("v.Precontact");
                //console.log("con---"+con);
            }
        });
        $A.enqueueAction(action);
    },
    createCasDetails: function(component,event,helper,responsedata){
        console.log("responsedata---"+responsedata.messageDisplay);
        if(responsedata.messageDisplay == false){
            var Acc = component.get("v.Preaccount");
            var con = component.get("v.Precontact");
            console.log("Acccase---"+Acc);
            console.log("concase---"+con);
            var createCaseEvent = $A.get("e.force:createRecord");
            createCaseEvent.setParams({
                "entityApiName": "Case",
                "defaultFieldValues": {
                    'Case_Type__c'     : 'Do Not Call List Request',
                    'Account'        : Acc,
                    'Contact'        : con,
                    'Opportunity__c': responsedata.caseOppId
                }
            });
            createCaseEvent.fire();
        }
    },
})

Apex Class:

public with sharing class RemovefromDNCcontroller {

    @AuraEnabled public string caseaccId{get;set;}
    @AuraEnabled public string caseContactId{get;set;}
    @AuraEnabled public string caseOppId{get;set;}
    @AuraEnabled public string message{get;set;}
    @AuraEnabled public boolean messageDisplay{get;set;}
    
    @AuraEnabled 
    public static RemovefromDNCcontroller Oppdetails (Id OppId){
        RemovefromDNCcontroller rfd = new RemovefromDNCcontroller();
         rfd.messageDisplay = false;
        Opportunity o = [select id, Name,ownerId, AccountId, Account.PersonContactId, Do_Not_Call__c from Opportunity where Id =: OppId];
        system.debug('o----'+o);
        if(o.Do_Not_Call__c == true){
            system.debug('rfd 24'+ rfd.message);
            rfd.caseOppId = o.Id;
            rfd.caseContactId = o.Account.PersonContactId;
            rfd.caseaccId = o.AccountId;
            system.debug('caseContactId ==='+rfd.caseContactId);
            system.debug('caseaccId ==='+rfd.caseaccId);
            return rfd;
        }else{
            rfd.message = system.Label.Remove_from_DNC_Alert;
            rfd.messageDisplay = true;
            system.debug('rfd 32'+ rfd.message);
            return rfd;
            
        }
        
    }
    @AuraEnabled 
    public static Id accountPreCheck (Id AccountcheckId){
        system.debug('AccountcheckId--'+AccountcheckId);
        return AccountcheckId;
    }
    @AuraEnabled 
    public static Id contactPreCheck (Id ContactcheckId){
        system.debug('ContactcheckId--'+ContactcheckId);
        return ContactcheckId;
    }
}

In Helper, method createCasDetails, values in 
console.log("Acccase---"+Acc);
console.log("concase---"+con);
are not coming due to which values in Account and Contact are not pre-populating.
Please help.