Skip to main content
<aura:application extends="force.slds"> <c:abc a="a" b="a,b,c" c="c" /> </aura:application> 
 <aura:application extends="force.slds"> <c:abc a="a" b="a,b,c" c="c" /> </aura:application> 
<template> {d} {e} <template if:true={deWired}> Data: {deWired.data} Error: {deWired.error} </template> </template> 
 <template> {d} {e} <template if:true={deWired}> Data: {deWired.data} Error: {deWired.error} </template> </template> 
import { LightningElement, wire, track, api } from 'lwc'; import getDE from '@salesforce/apex/ABCCont.getDE'; export default class Abc extends LightningElement { @api a; @api b; @api c; @wire(getDE, { a:this.a, b:this.b.split(','), c:this.c}) deWired = {}; @track d; @track e; @track error; connectedCallback() { getDE({ a:this.a, b:this.b.split(','),c:this.c}).then(result=>{ this.d = result.d; this.e = result.e; }).catch(error => { this.error = error; }); } } 
 import { LightningElement, wire, track, api } from 'lwc'; import getDE from '@salesforce/apex/ABCCont.getDE'; export default class Abc extends LightningElement { @api a; @api b; @api c; @wire(getDE, { a:this.a, b:this.b.split(','), c:this.c}) deWired = {}; @track d; @track e; @track error; connectedCallback() { getDE({ a:this.a, b:this.b.split(','),c:this.c}).then(result=>{ this.d = result.d; this.e = result.e; }).catch(error => { this.error = error; }); } } 
@wire(getDE, { a:this.a, b:this.b.split(','), c:this.c}) deWired = {}; 
 @wire(getDE, { a:this.a, b:this.b.split(','), c:this.c}) deWired = {}; 
public inherited sharing class ABCCont { @AuraEnabled(cacheable=true) public static Map<String, Object> getDE(String a, List<String> b, String c) { return new Map<String, Object>{'d'=>'d','e'=>'e'}; } } 
 public inherited sharing class ABCCont { @AuraEnabled(cacheable=true) public static Map<String, Object> getDE(String a, List<String> b, String c) { return new Map<String, Object>{'d'=>'d','e'=>'e'}; } } 
<aura:application extends="force.slds"> <c:abc a="a" b="a,b,c" c="c" /> </aura:application> 
<template> {d} {e} <template if:true={deWired}> Data: {deWired.data} Error: {deWired.error} </template> </template> 
import { LightningElement, wire, track, api } from 'lwc'; import getDE from '@salesforce/apex/ABCCont.getDE'; export default class Abc extends LightningElement { @api a; @api b; @api c; @wire(getDE, { a:this.a, b:this.b.split(','), c:this.c}) deWired = {}; @track d; @track e; @track error; connectedCallback() { getDE({ a:this.a, b:this.b.split(','),c:this.c}).then(result=>{ this.d = result.d; this.e = result.e; }).catch(error => { this.error = error; }); } } 
@wire(getDE, { a:this.a, b:this.b.split(','), c:this.c}) deWired = {}; 
public inherited sharing class ABCCont { @AuraEnabled(cacheable=true) public static Map<String, Object> getDE(String a, List<String> b, String c) { return new Map<String, Object>{'d'=>'d','e'=>'e'}; } } 
 <aura:application extends="force.slds"> <c:abc a="a" b="a,b,c" c="c" /> </aura:application> 
 <template> {d} {e} <template if:true={deWired}> Data: {deWired.data} Error: {deWired.error} </template> </template> 
 import { LightningElement, wire, track, api } from 'lwc'; import getDE from '@salesforce/apex/ABCCont.getDE'; export default class Abc extends LightningElement { @api a; @api b; @api c; @wire(getDE, { a:this.a, b:this.b.split(','), c:this.c}) deWired = {}; @track d; @track e; @track error; connectedCallback() { getDE({ a:this.a, b:this.b.split(','),c:this.c}).then(result=>{ this.d = result.d; this.e = result.e; }).catch(error => { this.error = error; }); } } 
 @wire(getDE, { a:this.a, b:this.b.split(','), c:this.c}) deWired = {}; 
 public inherited sharing class ABCCont { @AuraEnabled(cacheable=true) public static Map<String, Object> getDE(String a, List<String> b, String c) { return new Map<String, Object>{'d'=>'d','e'=>'e'}; } } 
added 346 characters in body
Source Link
Patlatus
  • 18.8k
  • 14
  • 89
  • 207

[![enter image description here][1]][1]enter image description here

it works like a charm. So looks like the problem is with wired property. Is there any way to use a wired property here? Are we obliged to use only Imperative Apex in this case? [1]: https://i.sstatic.net/d0RVW.png

Apex controller is irrelevant here, but just for reference listing of dummy ABCCont

public inherited sharing class ABCCont { @AuraEnabled(cacheable=true) public static Map<String, Object> getDE(String a, List<String> b, String c) { return new Map<String, Object>{'d'=>'d','e'=>'e'}; } } 

[![enter image description here][1]][1]

it works like a charm. So looks like the problem is with wired property. Is there any way to use a wired property here? Are we obliged to use only Imperative Apex in this case? [1]: https://i.sstatic.net/d0RVW.png

enter image description here

it works like a charm. So looks like the problem is with wired property. Is there any way to use a wired property here? Are we obliged to use only Imperative Apex in this case?

Apex controller is irrelevant here, but just for reference listing of dummy ABCCont

public inherited sharing class ABCCont { @AuraEnabled(cacheable=true) public static Map<String, Object> getDE(String a, List<String> b, String c) { return new Map<String, Object>{'d'=>'d','e'=>'e'}; } } 
Source Link
Patlatus
  • 18.8k
  • 14
  • 89
  • 207

Unable to pass parameters to wired property in LWC

Unable to pass parameters to wired property in LWC.

I have a standalone app

<aura:application extends="force.slds"> <c:abc a="a" b="a,b,c" c="c" /> </aura:application> 

and Lightning Web Component abc.

Listing of abc.html

<template> {d} {e} <template if:true={deWired}> Data: {deWired.data} Error: {deWired.error} </template> </template> 

Listing of abc.js

import { LightningElement, wire, track, api } from 'lwc'; import getDE from '@salesforce/apex/ABCCont.getDE'; export default class Abc extends LightningElement { @api a; @api b; @api c; @wire(getDE, { a:this.a, b:this.b.split(','), c:this.c}) deWired = {}; @track d; @track e; @track error; connectedCallback() { getDE({ a:this.a, b:this.b.split(','),c:this.c}).then(result=>{ this.d = result.d; this.e = result.e; }).catch(error => { this.error = error; }); } } 

I am trying to use wired property deWired and wire it to the method which requires three parameters which I want to pass from another app or component which references this component. However, when I try to do this, I receive an error

This page has an error. You might just need to refresh it. Failed to initialize a component [Cannot read property 'a' of undefined] Failing descriptor: {c:App} 

[![enter image description here][1]][1]

When I comment out lines

@wire(getDE, { a:this.a, b:this.b.split(','), c:this.c}) deWired = {}; 

it works like a charm. So looks like the problem is with wired property. Is there any way to use a wired property here? Are we obliged to use only Imperative Apex in this case? [1]: https://i.sstatic.net/d0RVW.png