this is what I'm sending to apex:

filter: {value: "1"}

That is exported via this function in my js controller:

@api exportData(){
    let data = {};
    if(this.isInput || this.isSelect || this.isBoolean){
        data = {'value' : this.filter.value}
    }else if(this.isComposable){
        let filter = this.template.querySelector('c-lwc-filter');
        data = {'filter' : filter.exportData()};
    }else if(this.isSelectable){
        let selectedFilter = this.template.querySelector('c-lwc-filter');
        data = {'selectedOption' : this.filter.selectedOption, 'selectedFilter' : selectedFilter.exportData()};
    }else if(this.isMultiSelect){
        data = {'selected' : this.filter.selected};
    return data;

it is the line that says let filter = this.template...etc and then data = {'filter': filter.exportData()}

In Apex, the import does this:

public virtual void import(Map<String, Object> o) {
        selectedOption = (String) o.get('selectedOption');
        filter.import((Map<String, Object>) o.get('filter'));

The line that says filter.import and does the conversion. How do I avoid this error?

EDIT: This is what is rendering in the html:

<template if:true={isComposable}>

The c-lwc-filter is the 'filter' in the export. I'm trying to export that with the value that the user inputs. (hence, the {value: "1"})

In apex, I'm also calling the import methods, from another method:

public static List<Account> importFilters(List<Map<String, Object>> objs){
    QueryFilters q = getFilters();
    String query;
    for(Integer i = 0; i < q.filters.size(); i++){
    query = QueryFilters.build('select Name, AnnualRevenue, Industry from Account where', q.filters);
    return Database.query(query);
  • You've left out several pieces of code that would make this question make sense. As it is, we can generally tell that something's wrong, but I'm not entirely sure what is wrong, without more context. – sfdcfox Dec 17 '20 at 13:22
  • I'm really sorry. I'm editing it and adding some more code – joacoiudica Dec 17 '20 at 13:24
  • in the import method, the selectedOption and filter are properties of the class that contains that method, so, it is assigning the imported values to those properties. – joacoiudica Dec 17 '20 at 13:29
  • As the error says Map<ANY, ANY> to Map<String, ANY> We are getting data as List<Map<Object, Object>> and you are reading that so simply get data as List<Map<Object, Object>> and do the conversion of the Map keys and values. – itzmukeshy7 Dec 17 '20 at 13:34
  • You mean the list received by parameter in the importFilters method? the thing is, the other exports are fine, its just that one that doesnt work. I mean, the others are well imported, they don't throw a conversion error – joacoiudica Dec 17 '20 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.