• Qiuyan LIU
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Hello everyone,

In a Lightning component, I am trying to call Apex function and get a String return value,
The function I called in Apex : 
public with sharing class UserSearch {
    ....
    @AuraEnabled
    public static String createPersonAccount(Account account) {
       System.debug('createPersonAccount Function begins...');
       return 'Test !'; 
    }
...
}

in the comononent controller : 
   var account = component.get("v.account");
        var action = component.get("c.createPersonAccount");
        action.setParams({
            'account' : account
        });  
        action.setCallback(this, function(actionResult) { 
            var returnValue = actionResult.getReturnValue();           
        });
        $A.enqueueAction(action);

With the same code, sometimes I can get the return value correctly, but most of the time, what I get is like this :

Sorry the photo is not very clear, 
the message are  : 
   error: Array[1]
        0: Object
             message: "Disconnected or Canceled"
         __proto__: Object
    length: 1
    __proto__: Array[0]
 
id: "158;a"
returnValue: undefined
state: "INCOMPLETE"
__proto__: Action

User-added image

Could any one help me please ? 
 
Hello, I am trying to use "force:inputField" to create type-specific input component implementation based on the data type to Create Account Record. 

Here is what I did : 

In cmp file : 

<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:attribute name="account" type="Account" default="{ sobjectType: 'Account' }"/>
 <force:inputField value="{!v.account.Name}" />

In Controller :
doInit: function(component, evt, helper) {
         var action = component.get("c.getAccount");
        action.setCallback(this, function(a) {
            console.log(a.getReturnValue());
                component.set("v.account", a.getReturnValue());
            
        });
        $A.enqueueAction(action);
    },

I can see the v.account value if I use ui:inputText, so it is not the problem of javascript or apex code. I did not got any error,  only a blank page with nothing in html markup, the javascript function is not event executed. 

Please help me ! Thanks a lot 
Hello, I am trying to use "force:inputField" to create type-specific input component implementation based on the data type to Create Account Record. 

Here is what I did : 

In cmp file : 

<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:attribute name="account" type="Account" default="{ sobjectType: 'Account' }"/>
 <force:inputField value="{!v.account.Name}" />

In Controller :
doInit: function(component, evt, helper) {
         var action = component.get("c.getAccount");
        action.setCallback(this, function(a) {
            console.log(a.getReturnValue());
                component.set("v.account", a.getReturnValue());
            
        });
        $A.enqueueAction(action);
    },

I can see the v.account value if I use ui:inputText, so it is not the problem of javascript or apex code. I did not got any error,  only a blank page with nothing in html markup, the javascript function is not event executed. 

Please help me ! Thanks a lot 
Hello everyone,

In a Lightning component, I am trying to call Apex function and get a String return value,
The function I called in Apex : 
public with sharing class UserSearch {
    ....
    @AuraEnabled
    public static String createPersonAccount(Account account) {
       System.debug('createPersonAccount Function begins...');
       return 'Test !'; 
    }
...
}

in the comononent controller : 
   var account = component.get("v.account");
        var action = component.get("c.createPersonAccount");
        action.setParams({
            'account' : account
        });  
        action.setCallback(this, function(actionResult) { 
            var returnValue = actionResult.getReturnValue();           
        });
        $A.enqueueAction(action);

With the same code, sometimes I can get the return value correctly, but most of the time, what I get is like this :

Sorry the photo is not very clear, 
the message are  : 
   error: Array[1]
        0: Object
             message: "Disconnected or Canceled"
         __proto__: Object
    length: 1
    __proto__: Array[0]
 
id: "158;a"
returnValue: undefined
state: "INCOMPLETE"
__proto__: Action

User-added image

Could any one help me please ?