Created
April 2, 2020 19:19
-
-
Save justin-lyon/549b3153c860efe716b62c27ad08040b to your computer and use it in GitHub Desktop.
Get Record Type by Name from LWC RecordTypeInfos API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"012000000000000AAA":{ | |
"available":true, | |
"defaultRecordTypeMapping":false, | |
"master":true, | |
"name":"Master", | |
"recordTypeId":"012000000000000AAA" | |
}, | |
"0121k000000kYckAAE":{ | |
"available":true, | |
"defaultRecordTypeMapping":true, | |
"master":false, | |
"name":"Record Type 1", | |
"recordTypeId":"0121k000000kYzkAAE" | |
}, | |
"0121k000000kYcpAAE":{ | |
"available":true, | |
"defaultRecordTypeMapping":false, | |
"master":false, | |
"name":"Record Type 2", | |
"recordTypeId":"0121k000000kYzpAAE" | |
}, | |
"0121k000000kYcuAAE":{ | |
"available":true, | |
"defaultRecordTypeMapping":false, | |
"master":false, | |
"name":"Record Type 3", | |
"recordTypeId":"0121k000000kYzuAAE" | |
}, | |
"0121k000000kYczAAE":{ | |
"available":true, | |
"defaultRecordTypeMapping":false, | |
"master":false, | |
"name":"Record Type 4", | |
"recordTypeId":"0121k000000kYzzAAE" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getRecordTypeId (name) { | |
// Map of RT Info by RT Id | |
const rtis = this.objectInfo.data.recordTypeInfos; | |
// Return first RT Info by Name | |
return Object.keys(rtis).find(rti => rtis[rti].name === name); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment