0

I'm trying to set values depending on the chosen variable of lightning-combobox so i created the following javascript

get timing() {
        return [
            { label: 'Weekly', value:'weely' },
            { label: 'Monthly', value:'monthly'},
            { label: 'Code',value:'code' },
        ];
    }

    handleMonthChange(event){
        this.month=event.target.value;
    }
    handleDoWChange(event){
        this.DoW=event.target.value;
    }
    handleTimingChange(){
    if (this.template.querySelector('timing').value="weekly"){
        this.minute='0';
        this.hour='0';
        this.DoM='*';
    }
    else if(this.template.querySelector('timing').value="monthly"){
        this.minute='0';
        this.hour='0';
        this.DoM='1';
        this.month='*';
        this.DoW='* ';
    }
    else{
        this.minute='0';
        this.hour='0';
        this.DoM='1';
        this.DoW='1';
        this.month='1';

    }
}

All values are already tracked. And the function that are not mentioned here for handling changes also work. The only I am having is with these functions but i can't detect where i did the error.

Edit: The page is functioning normally but when i select anything from the combobox for example - code, weekly or monthly - I get an alert that says error and with a text field to explain how i got the error

  • Can you provide a playground link with reproducible error?? And can you add exact verbatim of the error message? – Pranay Jaiswal Jul 19 at 11:44
  • @PranayJaiswal these are the things i can see additionaly in the error [NoErrorObjectAvailable] Script error. a()@https://static.lightning.force.com/eu26/auraFW/javascript/dOMRLHt4yryfVjId3qhSww/aura_prod.js:903:85 {anonymous}()@https://static.lightning.force.com/eu26/auraFW/javascript/dOMRLHt4yryfVjId3qhSww/aura_prod.js:903:278 m.dispatchEvent()@https://static.lightning.force.com/eu26/auraFW/javascript/dOMRLHt4yryfVjId3qhSww/aura_prod.js:12:5396 m.handleSelect()@https://curious-hawk-48tqce-dev-ed.lightning.force.com/components/lightning/combobox.js:2:4850 – Rami Abou Khalil Jul 19 at 11:46
2

if condition should be a comparison.

this.template.querySelector('timing').value==="weekly"
this.template.querySelector('timing').value==="monthly"

It should be === instead of=.
Note: = is for assignment, == is for comparison without datatype comparison ("89"==89) and === is for comparison with datatype comparison("89"!=89).

Important: Install extensions for LWC in vs-code (eslint, lwc-extensions etc). With these extensions you would have known about this problem immediately.

  • I didnt notice i was missing that. But i'm getting the same alert appearing – Rami Abou Khalil Jul 19 at 13:39
  • error is from handleSelect(), can you show that method also here? (did you implement it?) – salesforce-sas Jul 19 at 13:52
  • no I didn't implement it – Rami Abou Khalil Jul 19 at 14:33
  • so thats the error – salesforce-sas Jul 19 at 14:36

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.