1

I am trying to build a lightning component and I am really lost as to why I am getting this component error when trying to load the component.

Unable to find action 'getGType' on the controller of c:WLoanTerms

Here is the code I am using:

WLoanTerms.cmp:

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" controller ="LoanTest" >
    <aura:handler name="init" action="{!c.doInit}" value ="{!this}"/>
    <aura:attribute name="loan" type="LLC_BI__Loan__c"/>
    <aura:attribute name="gType" type="String"/>
    <aura:attribute name="memo" type="Credit_Memo_R__c"/>
    
    <lightning:recordEditForm recordId="recordId" objectApiName="Credit_Memo_R__c">
        <lightning:outputField fieldName="{!v.loan.LLC_BI__Description__c}" />
        <lightning:inputField fieldName="Current_Status__c" />
        <lightning:inputField fieldName="Equity_Cash_Out__c" />
        <lightning:inputField fieldName="{!v.loan.LLC_BI__Amount__c}"/>
        <lightning:inputField fieldName="Amortization__c" readonly="true" />
        <lightning:inputField fieldName="Interest_Type__c" readonly="true" />
        <lightning:inputField fieldName="Interest_Rate_Spread__c" readonly="true" />
        <lightning:inputField fieldName="{!v.loan.cm_Sub_Loan__r.cm_Rate_Floor__c}" readonly="true"/>
        <lightning:inputField fieldName="{!v.loan.cm_Sub_Loan__r.LLC_BI__Interest_Accrual_Method__c}" readonly="true"/>
    </lightning:recordEditForm>
    
</aura:component>

WLoanTermsController.js:

({
    doInit : function(component, event, helper) {
        helper.helperMethod(component);
       
        
        
    }
})

WLoanTermsHelper.js:

({
    helperMethod : function(component) {
        var action = component.get("c.getLoan");
        var theid = component.get("v.recordId");
        action.setParams({"memo" : theid});
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.loan", response.getReturnValue());
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
        $A.enqueueAction(action);
        
        var action2 = component.get("c.getGType");
        var theid = component.get("v.recordId");
        action2.setParams({"memo" : theid});
        action2.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.gType", response.getReturnValue());
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
        $A.enqueueAction(action2);
        
        var action3 = component.get("c.getMemo");
        var theid = component.get("v.recordId");
        action3.setParams({"memid" : theid});
        action3.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.memo", response.getReturnValue());
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
        $A.enqueueAction(action3);
    }
})

LoanTest.apxc:

public class LoanTest {
    @AuraEnabled
    
    public static LLC_BI__Loan__c getLoan(String memo){
            System.debug('madeloan');
        Credit_Memo_R__c gotMemo = getMemo(memo);
        String loanst = gotMemo.Loan__c; 
        list<LLC_BI__Loan__c> allLoans = [select LLC_BI__Account__r.Name, 
                                          cm_Opportunity_Lookup__r.Owner.Name,  
                                          cm_Credit_Analyst_Underwriter__r.Name,    
                                          LLC_BI__Description__c,   LLC_BI__Amount__c,   
                                          cm_Sub_Loan__r.LLC_BI__Term_Months__c,    
                                          cm_Sub_Loan__r.LLC_BI__Interest_Only_Months__c,   
                                          cm_Sub_Loan__r.LLC_BI__Amortized_Term__c, 
                                          cm_Sub_Loan__r.LLC_BI__Pricing_Basis__c,  
                                          cm_Sub_Loan__r.LLC_BI__Index__c,  
                                          cm_Sub_Loan__r.LLC_BI__Spread__c, 
                                          cm_Sub_Loan__r.LLC_BI__InterestRate__c,   
                                          cm_Sub_Loan__r.cm_Rate_Floor__c,  
                                          cm_Sub_Loan__r.LLC_BI__Interest_Accrual_Method__c,    
                                          LLC_BI__Product_Package__r.LLC_BI__Risk_Rating__c,    
                                          Application_Date__c, LLC_BI__CloseDate__c,    
                                          cm_Sub_Loan__r.LLC_BI__Maturity_Date__c,  
                                          cm_Sub_Loan__r.cm_Is_Payment_in_Kind__c,
                                          cm_Sub_Loan__r.LLC_BI__Prepayment_Penalty__c, 
                                          cm_Sub_Loan__r.LLC_BI__Prepayment_Penalty_Description__c, 
                                          LLC_BI__Total_Collateral_Value__c,    
                                          LLC_BI__Current_Total_Lendable_Value__c,  
                                          LLC_BI__Current_LTV__c,   
                                          LLC_BI__Account__r.cm_NAICS_Code__r.cm_NAICS_Code__c, 
                                          LLC_BI__Account__r.cm_NAICS_Code__r.cm_NAICS_Description__c,  
                                          HVCRE_Reportable__c,  LLC_BI__HMDA_Reportable__c,
                                          cm_Sub_Loan__r.Primary_Source_of_Repayment__c,    
                                          cm_Sub_Loan__r.Secondary_Source_of_Repayment__c,  
                                          cm_Sub_Loan__r.Tertiary_Source_of_Repayment__c,   
                                          id,   LLC_BI__Account__r.Account_ID_Long__c,  
                                          LLC_BI__Is_Main__c,   
                                          LLC_BI__Loan_Collateral_Aggregate__r.Id,  
                                          LLC_BI__Loan_Collateral_Aggregate__r.Name 
                                          from LLC_BI__Loan__c where id = :loanst];
        return allLoans.get(0);
    }
    
    public static Credit_Memo_R__c getMemo(String memid){
        list<Credit_Memo_R__c> memoList = [select Amortization__c,
                                           CreatedById,
                                           Name,
                                           Current_Status__c,
                                           Equity_Cash_Out__c,
                                           Interest_Rate_Spread__c,
                                           Interest_Type__c,
                                           LastModifiedById,
                                           Loan__c
                                           from Credit_Memo_R__c where id = :memid];
        Credit_Memo_R__c gotMemo = memoList.get(0);
        return gotMemo;
    }
    

    
    public static List<LLC_BI__Legal_Entities__c> getGuarantors(String memo){
        System.debug('got g');
        LLC_BI__Loan__c loan = getLoan(memo);
        String loanid = loan.Id;
        list<LLC_BI__Legal_Entities__c> out = [select LLC_BI__Borrower_Type__c, 
                                 LLC_BI__Account__r.Name,
                                 LLC_BI__Contingent_Type__c,    LLC_BI__Ownership__c,
                                 LLC_BI__Contingent_Amount__c,  LLC_BI__Guaranty_Amount__c,
                                 LLC_BI__Limited_Guaranty_Amount__c,    LLC_BI__Loan__r.Id,
                                 Id, LLC_BI__Account__r.Account_ID_Long__c
                                 from LLC_BI__Legal_Entities__c where LLC_BI__Loan__r.Id = :loanid 
                                 and LLC_BI__Borrower_Type__c = 'Guarantor'
        ];
     return out;   
    }
    
    public static String getGType(String memo){
        List<LLC_BI__Legal_Entities__c> gs = getGuarantors(memo);
        boolean move = true;
        for(Integer i = 0; i < gs.size(); i++){
            LLC_BI__Legal_Entities__c thisg = gs.get(i);
            if(thisg.LLC_BI__Contingent_Type__c!='Joint & Several'){
                move = false;
            }
        }
        if(move){
            return 'Full Recorse';
                }else{
                    LLC_BI__Legal_Entities__c thisg = gs.get(0);
                    if(thisg.LLC_BI__Contingent_Type__c == 'Joint & Several'){
                        return 'Partial Recourse';
                    }else{
                        return 'No Recourse';
                    }
                }
    }

}

I know that is a lot of code to go through, but I am so lost. Mainly because, as you can see getGType, is in a method in the controller. So I really don't know what could be causing this. Any help you can give would be much much appreciated.

1 Answer 1

2

Every method which is being referred from Aura or LWC component needs to be annotated with @AuraEnabled

I see you are missing that from getGType method in controller.

@AuraEnabled
public static String getGType(String memo){
    List<LLC_BI__Legal_Entities__c> gs = getGuarantors(memo);
    boolean move = true;
    for(Integer i = 0; i < gs.size(); i++){
        LLC_BI__Legal_Entities__c thisg = gs.get(i);
        if(thisg.LLC_BI__Contingent_Type__c!='Joint & Several'){
            move = false;
        }
    }
    if(move){
        return 'Full Recorse';
            }else{
                LLC_BI__Legal_Entities__c thisg = gs.get(0);
                if(thisg.LLC_BI__Contingent_Type__c == 'Joint & Several'){
                    return 'Partial Recourse';
                }else{
                    return 'No Recourse';
                }
            }
}

You need to fix getMemo method too as shown above. As I see that also being referred in Aura Component.

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.