I've created a component to update "Observations__c" value in Account Object. It is working fine, but I need to call it inside another component. But inside another component, it isn't working and I don't know what am I missing.

Component sparkAccount:

<aura:component implements="force:lightningQuickActionWithoutHeader,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" controller="getAccount">

<aura:handler name="init" action="{!c.init}" value="{!this}" />
<aura:attribute name="accounts" type="Account" />
<aura:attribute name="recordId" type="Id" />

<ltng:require styles="/resource/slds103/assets/styles/salesforce-lightning-design-system.min.css"/>

    <ui:inputText aura:id="client"
                  placeholder="Insira, caso necessário, comentários adicionais"
    <br />
    <ui:button class="form-control" aura:id="button" label="Anexar observação" press="{!c.save}"/>


Controller js:

init : function(component, event, helper) {
    var accId = component.get("v.recordId");
    var action = component.get("c.getAcct");

        "accountId": component.get("v.recordId")

    action.setCallback(this, function(data) {
        component.set("v.accounts", data.getReturnValue());

save : function(component, event, helper) {

    var action = component.get("c.saveAcct");
    var accounts = component.get("v.accounts");

    action.setParams({"act": accounts});

    console.log('save ran');


Apex Controller:

public class getAccount {
    public static Account getAcct(Id accountId){
        return (Account) Database.query( ' SELECT Name, Observations__c FROM Account WHERE Id =: accountId LIMIT 1 ' )[0];
    public static Account saveAcct(Account act){
        upsert act;
        return act;

I'm calling sparkAccount.cmp inside notifyClient.cmp like this:


But when I try to use it, I receive the following error: System.NullPointerException: Attempted to upsert a null list

It's not being able to get Account information I guess. Why?

1 Answer 1


recordId is not being set, because only top-level components will receive an Id when using force:hasRecordId, etc. Your top-level component needs to pass that information on.

<c:sparkAccount recordId="{!v.recordId}" />

Also, some pointers.

<aura:attribute name="recordId" type="Id" />

Do not define a recordId attribute if you're using any interface that provides a recordId. You can cause things to break.

<ltng:require styles="/resource/slds103/assets/styles/salesforce-lightning-design-system.min.css"/>

You should not import SLDS in your component; it should already be properly styled from a parent runtime.

<ui:inputText ...

This element doesn't style itself properly, and is deprecated. Use lightning:input instead.


This element doesn't style itself properly, and is deprecated. Use lightning:button instead.

  • Thank you! It helped me a lot!
    – Sabrina T.
    Commented Aug 12, 2021 at 13:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .