Sumchans
Sumchans

Reputation: 3784

salesforce lwc - wire adaptor not able to have declared track variables as arguments

I am trying to pull in picklist values of a field based on record type. The below works -

@wire(getPicklistValuesByRecordType, { objectApiName: 'Case', recordTypeId: '0123h000000kv04AAA' })
typePicklistValues({ error, data }) {
    if (data) {
        console.log(data.picklistFieldValues.Type.values)
        this.options = data.picklistFieldValues.Type.values;
    }
}

If I replace the ObjectAPIName & recordtype with a variable, it doesn't work -

@wire(getPicklistValuesByRecordType, { objectApiName: '$this.objectName', recordTypeId: '$this.recordTypeId' })
typePicklistValues({ error, data }) {
    if (data) {
        console.log(data.picklistFieldValues.Type.values)
        this.options = data.picklistFieldValues.Type.values;
    }
}

All those variables have the actual values, which I checked already, is there anything that I am doing wrong here?

Upvotes: 0

Views: 1267

Answers (1)

David Reed
David Reed

Reputation: 2759

You do not include this in reactive wire parameters.

Use

@wire(
    getPicklistValuesByRecordType, 
    { objectApiName: '$objectName', recordTypeId: '$recordTypeId' }
)

to achieve this reactivity.

Upvotes: 2

Related Questions