0

I have the following code in my component

<aura:if isTrue="{! not(empty(v.assignedto)) }"> 
                                        <lightning:input aura:id="assignedToInput" value="{#v.assignedto.value}"  label=""/>
                                    <aura:set attribute="else">
                                        <lightning:input aura:id="assignedToInput" value=""  class="slds-hide" label=""/>
                                    </aura:set>
                            </aura:if>

The following is the helper code

getAccountRequestListHelper : function(component,event,helper){
        console.log('inside get account list helper'+component.get("v.ucn"));

        var action = component.get("c.searchAccounts");
        console.log('Here 1');
        var assignedToId = component.find("assignedToInput1").get('v.value');
        console.log('Here 2'+assignedToId);
        console.log('assignedToInput'+assignedToId);
        .
        .
        .

here I am getting an error in line

var assignedToId = component.find("assignedToInput").get('v.value');

when assignedToInput1 is not populated in the component. The assignedToInput1 value is conditional. It will not always be populated. can anyone tell me how to get over this issue

3
  • did you create a duplicate account by mistake?
    – glls
    Commented Mar 23, 2018 at 14:42
  • I did. i am not being able to log in to my previous. Is there any way I can get it back?
    – Rimii
    Commented Mar 23, 2018 at 14:43
  • Moderators cannot merge accounts. You have to reach out to the CM team.
    – Adrian Larson
    Commented Mar 23, 2018 at 16:10

1 Answer 1

3

Something like this would avoid invoking get on an undefined value:

var input = component.find("assignedToInput1");
var assignedToId = input ? input.get('v.value') : null;
0

You must log in to answer this question.

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