Skip to main content
Karen Guaspari 님이 #Lightning Experience에 질문했습니다
I have a form where I am getting information to insert, once inserted I want to reset the form.  All fields will reset except lookup fields.  I tried several methods for resetting the Account lookup but whatever account name is displayed will not clear.  I am able to clear all other types of fields.  Can someone please let me know what needs to be done to clear a lookip field?

Here is the code:

<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable" access="GLOBAL">

    <aura:attribute name="newItem" type="AQB__Batch_Item__c" access="GLOBAL" default="{ sobjectType: 'AQB__Batch_Item__c', 'AQB__Account__c': '', 'AQB__Account__r': '', 'AQB__Method__c': '' }" />   

    <force:inputField aura:id="AccountLookup" value="{!v.newItem.AQB__Account__c}" />

    <force:inputField value="{!v.newItem.AQB__Method__c}" />

    <ui:button label="Reset" press="{!c.resetForm}" />   

</aura:component>

Controller:

({

    resetForm : function(component, event, helper) {

        component.set("v.newItem.AQB__Account__c", '');               

        component.set("v.newItem.AQB__Account__r", '');               

        component.set("v.newItem.AQB__Method__c", '');               

        component.set("v.newItem", {'sobjectType':'AQB__Batch_Item__c',

                'AQB__Account__c': '',

                'AQB__Account__r': '',

                'AQB__Method__c': ''});

        var item = component.get("v.newItem");

        item.AQB__Account__c = '';

        item.AQB__Account__r = '';

        component.set("v.newItem", item);               

    }

})

 
답변 1개
  1. 2017년 5월 16일 오전 3:39

    I have the same issue and still looking for solution. However, the temporary solution i did is to refresh the page using: 

    $A.get('e.force:refreshView').fire();

0/9000