Skip to content

Instantly share code, notes, and snippets.

@justin-lyon
Last active October 27, 2019 06:32
Show Gist options
  • Save justin-lyon/241441fb2a4b0a9a78dbf4e0b83920f6 to your computer and use it in GitHub Desktop.
Save justin-lyon/241441fb2a4b0a9a78dbf4e0b83920f6 to your computer and use it in GitHub Desktop.
chain multiple wire adapters together to get picklist values dynamically by SObject and Field Name.
@wire(getObjectInfo, { objectApiName: ACCOUNT_OBJECT })
objectInfo;
@wire(getPicklistValues, { recordTypeId: '$objectInfo.defaultRecordTypeId', fieldApiName: 'Industry__c'})
propertyOrFunction;
// *** WIP
import { LightningElement, wire } from 'lwc'
import { getObjectInfo, getPicklistValues } from 'lightning/uiObjectInfoApi'
import ACCOUNT from '@salesforce/schema/Account'
const MASTER_RT = '012000000000000AAA'
export default class MdtRecordtyper extends LightningElement {
@wire(getObjectInfo, { objectApiName: ACCOUNT })
objectInfo
@wire(getPicklistValues, { recordTypeId: '$objectInfo.defaultRecordTypeId', fieldApiName: 'Type' })
wiredPicklistValues ({ error, data }) {
console.log('account', ACCOUNT)
console.log('account info', this.objectInfo)
console.log('account default rt', this.objectInfo.defaultRecordTypeId)
if (error) {
console.error('Error getting picklistvalues', error)
return
}
console.log('picklistvalues', data)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment