0

I'm trying get accountId with lightning component. I developed custom controller,controller.js and component. Everything looks true but I have error and it doesnt work. Error is:

Unfortunately, there was a problem. Please try again. If the problem continues, get in touch with your administrator with the error ID shown here and any other related details. Action failed: forceChatter:lightningComponent$controller$doInit [Error while creating content for lightning component quick action] quickActionHandlerHelper.js failed to create component - forceChatter:lightningComponent

This is my component

<aura:component controller="GetAccountController" implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
    <aura:handler name="init" action="{!c.doInit}" value="{!this}" access="global" />
</aura:component>

This is my custom contorller

global with sharing class GetAccountController {

    @AuraEnabled
    global static void setAccountId(Id actId) {
        try{

          Account ac = new Account(ID=actId,Site=actID);
          update ac;  
        }
        catch(Exception e){
            System.debug(e.getMessage());
        }               
    }
}

This is my controller.js

({
    doInit : function(component, event, helper) {

    var artId = component.get("v.actId");

    console.log(artId);

    action.setParams({
        "artId":artId
    });
    // Queue this action to send to the server
    $A.enqueueAction(action);
}
})

and this is my helper.js

({
helperMethod : function() {

}
})
2

The force:hasRecordId (thanks to sfdcfox for the link and correction) interface you're declaring provides a recordId attribute that you should use to access the record Id, via component.get("v.recordId"); You do not have an attribute actId, which you try to access. Presumably your error is happening somewhere within the init handler for that reason, which then results in the inscrutable error message you're receiving.

You also never declare action in your init method, so you'll get an error there too. You need to get controller actions with component.get("c.myActionName");

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.