Can someone help me to find where is the problem. Il my controller:

    execute : function(component, event, helper) {
        var action = component.get('c.Myclass'); 
        var InvoiceNum = 'testInvoice';
        var InvoiceAcc =component.get('v.AccountId__c'); 
            "invoiceNumber" :InvoiceNum , "accountId" : InvoiceAcc
        action.setCallback(this, function(a){
            var state = a.getState(); // get the response state
            if(state == 'SUCCESS') {
                alert('Demande de mise \xe0 jour effectu\xe9e');
                 txt = 'There was an error on this page.\n\n';
                 txt += 'Click OK to continue.\n\n';
          $A.getCallback(function() {
        }), 1000


the value of component.get('v.AccountId__c'); returns "Undefined" even if my object has an account Id this doesn't work only in lightning

here is my .cmp :

<aura:component controller="Mymethod" >
        <aura:handler name='init' value='{!this}' action="{!c.execute}"/>
        <aura:set attribute="componentString" value="false"></aura:set>
        <div style="height: 6rem;">
        <div role="status" class="slds-spinner slds-spinner_large slds-spinner_brand">
            <span class="slds-assistive-text">Loading</span>
            <div class="slds-spinner__dot-a"></div>
            <div class="slds-spinner__dot-b"></div>
  • 2
    There's no AccountId__c value specified. Where should this be coming from? – sfdcfox May 2 at 13:10
  • My opened object – SF trainer May 2 at 13:11
  • I want to get my object AccountId :) , i don't know if it's clear for you – SF trainer May 2 at 13:12
  • You'll need to use force:hasRecordId and force:recordData, then you can get the AccountId__c field from there. – sfdcfox May 2 at 13:14
  • I tried this and doesn't work too: component.get('v.Incoice__c.AccountId__c'); – SF trainer May 2 at 13:14

Your Answer

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

Browse other questions tagged or ask your own question.