• Renato Barucco 11
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies

I have an Array in LWC that have these values:

[
    {
        "apiName": "Designer_Hier__c",
        "filterItems": [
            {
                "label": "LP",
                "selected": false,
                "value": "Designer_Hier__c = 'LP'"
            },
            {
                "label": "OTHER NON RINSE OFF TREATMENT",
                "selected": false,
                "value": "Designer_Hier__c = 'OTHER NON RINSE OFF TREATMENT'"
            }
        ],
        "header": "Grife"
    },
    {
        "apiName": "Brand_Hier__c",
        "filterItems": [
            {
                "label": "COLOR SUPREME",
                "selected": false,
                "value": "Brand_Hier__c = 'COLOR SUPREME'"
            }
        ],
        "header": "Marca"
    },
    {
        "apiName": "SubBrand_Hier__c",
        "filterItems": [
            {
                "label": "COLOR SUPREME",
                "selected": false,
                "value": "SubBrand_Hier__c = 'COLOR SUPREME'"
            }
        ],
        "header": "Sub-marca"
    },
    {
        "apiName": "Reference_Hier__c",
        "filterItems": [
            {
                "label": "COLOR SUPREME 50ML T",
                "selected": false,
                "value": "Reference_Hier__c = 'COLOR SUPREME 50ML T'"
            }
        ],
        "header": "Referência"
    },
    {
        "apiName": "Color_Hier__c",
        "filterItems": [
            {
                "label": "BRONZE 7,41",
                "selected": false,
                "value": "Color_Hier__c = 'BRONZE 7,41'"
            }
        ],
        "header": "Nuance"
    },
    {
        "apiName": "Axis_Hier__c",
        "filterItems": [
            {
                "label": "HAIR",
                "selected": false,
                "value": "Axis_Hier__c = 'HAIR'"
            }
        ],
        "header": "Eixo"
    },
    {
        "apiName": "SubAxis_Hier__c",
        "filterItems": [
            {
                "label": "HAIR COLOR",
                "selected": false,
                "value": "SubAxis_Hier__c = 'HAIR COLOR'"
            }
        ],
        "header": "Sub-eixo"
    },
    {
        "apiName": "Class_Hier__c",
        "filterItems": [
            {
                "label": "OXYDATION HAIR COLOR OXYDANTS",
                "selected": false,
                "value": "Class_Hier__c = 'OXYDATION HAIR COLOR OXYDANTS'"
            }
        ],
        "header": "Classe"
    },
    {
        "apiName": "FuntionName__c",
        "filterItems": [
            {
                "label": "OXIDIZATION HAIR COLOR",
                "selected": false,
                "value": "FuntionName__c = 'OXIDIZATION HAIR COLOR'"
            }
        ],
        "header": "Função"
    },
    {
        "apiName": "Category__c",
        "filterItems": [
            {
                "label": "COLORAÇÃO",
                "selected": false,
                "value": "Category__c = 'COLORAÇÃO'"
            }
        ],
        "header": "Categoria"
    }
]


I want to change the header value of the array if the logged in user has a defined language (en-US, pt-BR, es).

I will use the 

import LANG from '@salesforce/i18n/lang'

and change the header value for each language if LANG = one of these three languages.

How I call the function:

@wire(initFilters, {filterVal: '$list', doInit: '$initDo', existingFiltersStr: '$existingFilters'})
    wiredinitFilters({error, data}) {
        if(data) {
            this.filterObjs = data
            this.error = undefined
        }
        if(error) {
            this.filterObjs = undefined
            this.error = error
        }
    }

How I get this array:

this.temp = this.filterObjs.filters

how can I loop through the array and change these values in LWC?

I'm trying to implement a logic for Product Category Status Channel but I'm stuck with this error: ReferenceError: label is not defined at eval.

This is the code I'm developing:

getFilters() {
        var action = initFilters
        var arrExisting = !(this.productsAlreadyInCart === undefined || this.productsAlreadyInCart === null) ? this.productsAlreadyInCart : []
        action({ 
            doInit : true,
            productsAlreadyInCart : JSON.stringify(arrExisting),
            existingFiltersStr : null
        }).then(response => {
            var vals = [
                label.Label_CreateOpportunity, 
                label.Label_ProductSearch, 
                label.Sopping_cart_title, 
                label.Label_AdditionalInformation]
                this.indicatorElements = vals
                this.filterObjs = response.filters
                this.mainObj = response
                this.triggerGetProds = true
                
                if (localStorage.getItem("showSaveSuccess") != null) {
                    this.showSaveSuccess = true
                    var mainObj = this.mainObj
                    
                    mainObj.messageType = 'success'
                    mainObj.messageToDisplay = label.Saved_Date
                    
                    this.mainObj = mainObj
                }
                
                console.log('mainObj ', this.mainObj)
                
                localStorage.removeItem("showSaveSuccess")
            }).catch(response => {
                var errors = response
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        this.showToast(label.ErrorMessage, errors[0].message)
                    }
                    this.error = errors
                    console.log('Errors ', this.error)
                } else {
                    this.showToast(label.ErrorMessage, label.UnknownError)
                }
            })
        }


How canI fix it?

Regards

I have an Array in LWC that have these values:

[
    {
        "apiName": "Designer_Hier__c",
        "filterItems": [
            {
                "label": "LP",
                "selected": false,
                "value": "Designer_Hier__c = 'LP'"
            },
            {
                "label": "OTHER NON RINSE OFF TREATMENT",
                "selected": false,
                "value": "Designer_Hier__c = 'OTHER NON RINSE OFF TREATMENT'"
            }
        ],
        "header": "Grife"
    },
    {
        "apiName": "Brand_Hier__c",
        "filterItems": [
            {
                "label": "COLOR SUPREME",
                "selected": false,
                "value": "Brand_Hier__c = 'COLOR SUPREME'"
            }
        ],
        "header": "Marca"
    },
    {
        "apiName": "SubBrand_Hier__c",
        "filterItems": [
            {
                "label": "COLOR SUPREME",
                "selected": false,
                "value": "SubBrand_Hier__c = 'COLOR SUPREME'"
            }
        ],
        "header": "Sub-marca"
    },
    {
        "apiName": "Reference_Hier__c",
        "filterItems": [
            {
                "label": "COLOR SUPREME 50ML T",
                "selected": false,
                "value": "Reference_Hier__c = 'COLOR SUPREME 50ML T'"
            }
        ],
        "header": "Referência"
    },
    {
        "apiName": "Color_Hier__c",
        "filterItems": [
            {
                "label": "BRONZE 7,41",
                "selected": false,
                "value": "Color_Hier__c = 'BRONZE 7,41'"
            }
        ],
        "header": "Nuance"
    },
    {
        "apiName": "Axis_Hier__c",
        "filterItems": [
            {
                "label": "HAIR",
                "selected": false,
                "value": "Axis_Hier__c = 'HAIR'"
            }
        ],
        "header": "Eixo"
    },
    {
        "apiName": "SubAxis_Hier__c",
        "filterItems": [
            {
                "label": "HAIR COLOR",
                "selected": false,
                "value": "SubAxis_Hier__c = 'HAIR COLOR'"
            }
        ],
        "header": "Sub-eixo"
    },
    {
        "apiName": "Class_Hier__c",
        "filterItems": [
            {
                "label": "OXYDATION HAIR COLOR OXYDANTS",
                "selected": false,
                "value": "Class_Hier__c = 'OXYDATION HAIR COLOR OXYDANTS'"
            }
        ],
        "header": "Classe"
    },
    {
        "apiName": "FuntionName__c",
        "filterItems": [
            {
                "label": "OXIDIZATION HAIR COLOR",
                "selected": false,
                "value": "FuntionName__c = 'OXIDIZATION HAIR COLOR'"
            }
        ],
        "header": "Função"
    },
    {
        "apiName": "Category__c",
        "filterItems": [
            {
                "label": "COLORAÇÃO",
                "selected": false,
                "value": "Category__c = 'COLORAÇÃO'"
            }
        ],
        "header": "Categoria"
    }
]


I want to change the header value of the array if the logged in user has a defined language (en-US, pt-BR, es).

I will use the 

import LANG from '@salesforce/i18n/lang'

and change the header value for each language if LANG = one of these three languages.

How I call the function:

@wire(initFilters, {filterVal: '$list', doInit: '$initDo', existingFiltersStr: '$existingFilters'})
    wiredinitFilters({error, data}) {
        if(data) {
            this.filterObjs = data
            this.error = undefined
        }
        if(error) {
            this.filterObjs = undefined
            this.error = error
        }
    }

How I get this array:

this.temp = this.filterObjs.filters

how can I loop through the array and change these values in LWC?