0

LWC code

Picklist component code

<div if:true={displayMultipicklistFields}>
 <lightning-dual-listbox name="Field Value"
label="Field Value"
source-label="Available"
 selected-label="Selected"
 options ={fieldValues}
 onchange={handleFieldValueChange}>
</lightning-dual-listbox>
</div>

 <lightning-button 
 label="Submit"
 onclick={handleSaveFilter}>
 </lightning-button>

eFile.js

   handleSaveFilter()
   {
   this.filterRec.FilterSequence__c += 1;


    saveFilter(
    {
        customFilter : this.filterRec
    }
).then(data=>{
    if(data =true)
    {
        this.dispatchEvent(
            new ShowToastEvent({
                title: 'Success!! Filter created successfully',
                message: '',
                variant: 'Success',
            }),
        );
        this.openFilterModelBox = false;
        this.handleFiltersBox();
    }
    else{
        this.dispatchEvent(
            new ShowToastEvent({
                title: 'error!! Filter not created',
                message: '',
                variant: 'error',
            }),
        );
    }
}).catch(error=>{
    this.dispatchEvent(
        new ShowToastEvent({
            title: 'error!! while saving filter '+error.message,
            message: '',
            variant: 'error',
        }),
    ); 
})
 }

I am using below apex class to create record

@AuraEnabled
public static Boolean createFilterRecord(CustFilter__c customFilter)
{
    System.debug('Custom filter field value'+customFilter.Field_Value__c);

    insert customFilter;
    return true;
}

Error while saving record

2
  • can your add picklist component code as well? Apr 23, 2020 at 12:38
  • @sanketkumar I have added picklist code please check it Apr 23, 2020 at 12:46

1 Answer 1

2

If you have an array, you need to convert it to a string first:

if(Array.isArray(this.filterRec.Field_Value__c)) {
  this.filterRec.Field_Value__c = this.filterRec.Field_Value__c.join(';');
}

This should place the field's value into the expected format.

4

You must log in to answer this question.

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