0

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?

0
5

Reactive properties are not $this.whatever, but rather just $whatever:

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

Reactive variables can only work on class properties, so the wire service presumes that you meant this.

1
  • 1
    Thanks sfdcfox, careless mistake, but still I wouldn't have figured that out. – Sumesh Chandran Jun 15 at 16:48

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.