0

I'm trying to pass a list of assets to the lwc from the controller but when reviewing the data, only the values of the standard fields are arriving, the custom fields do not appear

This is my controller

public with sharing class CarouselBannerController {
    @AuraEnabled(cacheable=true)
    public static List<Asset> getBanners() {
        List<Asset> ls = [
                            SELECT ID,Name,Activo__c,Audiciencias__c,url__c
                            FROM Asset
                            ORDER BY Name
                        ];
        Map<Id, Asset> m = new Map<Id, Asset>(ls);
        return ls;
        
    }
}

This is my carouselBanner.js

import { LightningElement,track,wire } from 'lwc';
import getBanners from '@salesforce/apex/CarouselBannerController.getBanners';


export default class CarouselBanner extends LightningElement {
    bannerResult;
    error;

    @wire(getBanners)
    wireBanners({error,data}){
        if(data){
            this.bannerResult = data;
            detail : this.bannerResult;
            console.log("resultado" + JSON.stringify(this.bannerResult))
        }else if (error){
            this.error = error;
            this.bannerResult = undefined;
        }
    }
}

This is my html

<template>
    <div class="slds-size_3-of-4">
        <div class="slds-box slds-box_x-small slds-text-align_center slds-m-around_x-small">Basic Carousel
            <lightning-carousel>
                <template if:true={bannerResult} for:each={bannerResult} for:item="banner">
                <lightning-carousel-image
                    src = {banner.url__c}
                    header = {banner.name}
                    description = {banner.Audiciencias__c}
                    alternative-text = "First card accessible description."
                >
                </lightning-carousel-image>
           </template>
           </lightning-carousel>
            <template if:true={errors}>
                <p>{errors}</p>
            </template>
        </div>
    </div>
</template>


the query has this data

| ID                  | NAME      | ACTIVO__C  | AUDICIENCIAS__C        | URL__C
|:------------------  | :-------- |:---------  |:---------------------  | ----------
| 02i19000003f5H0AAI  | Banner1   | false      | Brasil;Chile;Colombia  |www.google.com
| 02i19000003f46yAAA  | Banner2   | true       | Argentina              |https://player.vimeo.com/video/241135386
| 02i19000003f56wAAA  | Banner3   | true       | Colombia;Ecuador       |www.google.com

In the console.log only show me the error 

*Error: [LWC error]: Invalid template iteration for value "undefined" in [object:vm undefined (12)]. It must be an Array or an iterable Object*

and it only shows the values of the fields ID and NAME which are standard fields of the object

resultado[ {"Name":"Banner1","Id":"02i19000003f5H0AAI"}, {"Name":"Banner2","Id":"02i19000003f46yAAA"}, {"Name":"Banner3","Id":"02i19000003f56wAAA"} ]

but custom fields **Activo__c,Audiciencias__c,url__c** not appear , and i do not why

3
  • 2
    Can you post your html as well? – anxiousAvocado May 4 at 12:32
  • Just added the html – jamal_dt May 5 at 3:32
  • do you have permission to query the field? I do see the class is with sharing so make sure the profile has permission to the fields. – anxiousAvocado May 5 at 3:38

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.