Skip to main content
added 137 characters in body
Source Link
Sandy
  • 7
  • 1
  • 8

I have one list method like below

 @AuraEnabled
    public static List<String> getDetails(String AccName){
            List<Account> accList = new List<Account>([Select Id, Name from account where Name=:AccName]);
return accList;
}

listacNameList = new list(); List accList = new List([Select Id, Name from account where Name=:AccName]); for(account acc: accList ){ acNameList.add(acc.Name); } return acNameList ; }

in LWC i have input text where i need to show all Account but not duplicate
 <lightning-card  variant="narrow">
            <label class="slds-form-element__label">Select Account</label>
                <input data-id="inputFilter" onchange="" required value={accValues} name="input" list="filterList" placeholder="search account" />

                <datalist data-id="filterList" id="filterList" class="">
                    <template for:each={accDetails} for:item='item'>
                        <option key={item} value={item}>{item}</option>
                    </template>
                </datalist>
        </div>
    </lightning-card>

**JS**
accDetails = [];
getDetails({AccName: this.value})
        .then(result=>{
            if(result){
    this.accDetails= result;
    }

there are chances that i will get duplicate account Name in input filter which i dont want, i am not able to remove duplicate account Name from result. Please suggest

I have one list method like below

 @AuraEnabled
    public static List<String> getDetails(String AccName){
            List<Account> accList = new List<Account>([Select Id, Name from account where Name=:AccName]);
return accList;
}

in LWC i have input text where i need to show all Account but not duplicate
 <lightning-card  variant="narrow">
            <label class="slds-form-element__label">Select Account</label>
                <input data-id="inputFilter" onchange="" required value={accValues} name="input" list="filterList" placeholder="search account" />

                <datalist data-id="filterList" id="filterList" class="">
                    <template for:each={accDetails} for:item='item'>
                        <option key={item} value={item}>{item}</option>
                    </template>
                </datalist>
        </div>
    </lightning-card>

**JS**
accDetails = [];
getDetails({AccName: this.value})
        .then(result=>{
            if(result){
    this.accDetails= result;
    }

there are chances that i will get duplicate account Name in input filter which i dont want, i am not able to remove duplicate account Name from result. Please suggest

I have one list method like below

 @AuraEnabled
    public static List<String> getDetails(String AccName){

listacNameList = new list(); List accList = new List([Select Id, Name from account where Name=:AccName]); for(account acc: accList ){ acNameList.add(acc.Name); } return acNameList ; }

in LWC i have input text where i need to show all Account but not duplicate
 <lightning-card  variant="narrow">
            <label class="slds-form-element__label">Select Account</label>
                <input data-id="inputFilter" onchange="" required value={accValues} name="input" list="filterList" placeholder="search account" />

                <datalist data-id="filterList" id="filterList" class="">
                    <template for:each={accDetails} for:item='item'>
                        <option key={item} value={item}>{item}</option>
                    </template>
                </datalist>
        </div>
    </lightning-card>

**JS**
accDetails = [];
getDetails({AccName: this.value})
        .then(result=>{
            if(result){
    this.accDetails= result;
    }

there are chances that i will get duplicate account Name in input filter which i dont want, i am not able to remove duplicate account Name from result. Please suggest

added 43 characters in body
Source Link
Sandy
  • 7
  • 1
  • 8

I have one list method like below

 @AuraEnabled
    public static List<String> getDetails(String AccName){
            List<Account> accList = new List<Account>([Select Id, Name from account where Name=:AccName]);
return accList;
}

in LWC i have input text where i need to show all Account but not duplicate
 <lightning-card  variant="narrow">
            <label class="slds-form-element__label">Select Account</label>
                <input data-id="inputFilter" onchange="" required value={accValues} name="input" list="filterList" placeholder="search account" />

                <datalist data-id="filterList" id="filterList" class="">
                    <template for:each={accDetails} for:item='item'>
                        <option key={item} value={item}>{item}</option>
                    </template>
                </datalist>
        </div>
    </lightning-card>

**JS**
accDetails = [];
getDetails({AccName: this.value})
        .then(result=>{
            if(result){
    this.accDetails= result;
    }

there are chances that i will get duplicate account butName in input filter which i dont want, i am not able to remove duplicate valuesaccount Name from result. Please suggest

I have one list method like below

 @AuraEnabled
    public static List<String> getDetails(String AccName){
            List<Account> accList = new List<Account>([Select Id, Name from account where Name=:AccName]);
return accList;
}

in LWC i have input text where i need to show all Account but not duplicate
 <lightning-card  variant="narrow">
            <label class="slds-form-element__label">Select Account</label>
                <input data-id="inputFilter" onchange="" required value={accValues} name="input" list="filterList" placeholder="search account" />

                <datalist data-id="filterList" id="filterList" class="">
                    <template for:each={accDetails} for:item='item'>
                        <option key={item} value={item}>{item}</option>
                    </template>
                </datalist>
        </div>
    </lightning-card>

**JS**
accDetails = [];
getDetails({AccName: this.value})
        .then(result=>{
            if(result){
    this.accDetails= result;
    }

there are chances that i will get duplicate account but i am not able to remove duplicate values from result. Please suggest

I have one list method like below

 @AuraEnabled
    public static List<String> getDetails(String AccName){
            List<Account> accList = new List<Account>([Select Id, Name from account where Name=:AccName]);
return accList;
}

in LWC i have input text where i need to show all Account but not duplicate
 <lightning-card  variant="narrow">
            <label class="slds-form-element__label">Select Account</label>
                <input data-id="inputFilter" onchange="" required value={accValues} name="input" list="filterList" placeholder="search account" />

                <datalist data-id="filterList" id="filterList" class="">
                    <template for:each={accDetails} for:item='item'>
                        <option key={item} value={item}>{item}</option>
                    </template>
                </datalist>
        </div>
    </lightning-card>

**JS**
accDetails = [];
getDetails({AccName: this.value})
        .then(result=>{
            if(result){
    this.accDetails= result;
    }

there are chances that i will get duplicate account Name in input filter which i dont want, i am not able to remove duplicate account Name from result. Please suggest

Source Link
Sandy
  • 7
  • 1
  • 8

How to get unique values from result list in LWC

I have one list method like below

 @AuraEnabled
    public static List<String> getDetails(String AccName){
            List<Account> accList = new List<Account>([Select Id, Name from account where Name=:AccName]);
return accList;
}

in LWC i have input text where i need to show all Account but not duplicate
 <lightning-card  variant="narrow">
            <label class="slds-form-element__label">Select Account</label>
                <input data-id="inputFilter" onchange="" required value={accValues} name="input" list="filterList" placeholder="search account" />

                <datalist data-id="filterList" id="filterList" class="">
                    <template for:each={accDetails} for:item='item'>
                        <option key={item} value={item}>{item}</option>
                    </template>
                </datalist>
        </div>
    </lightning-card>

**JS**
accDetails = [];
getDetails({AccName: this.value})
        .then(result=>{
            if(result){
    this.accDetails= result;
    }

there are chances that i will get duplicate account but i am not able to remove duplicate values from result. Please suggest