0

I am working on a Lightning Component and want to create a record using lightning:recordEditForm. using lightning:recordEditForm is great because it allows us to create records without Apex.

However, I need to pass a RecordTypeId to that component and that's where I get stuck. I would like to find the proper recordTypeId clientside so that I don't need an Apex controller that queries the recordTypes and returns them just so I can select the proper Id given a recordType name.

Is it possible to do it entirely clientside?

With the new Lightning Web Components, we have a wire adapter to get Object Info: https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.reference_wire_adapters_object_info

Is there something similar for the 'classic' Lightning Components? Maybe with the Lightning Data Service?

0

The hasPageReference interface provides pagereference object and it's property called state includes RecordTypeId. See the answer below: https://salesforce.stackexchange.com/a/227943/61793

  • Even with links to SFSE, I think it'd be preferable to reproduce the important bits in this answer. – Derek F Dec 18 '19 at 15:49
  • If you can put the actual solution in your answer (instead of linking) then I'll be glad to upvote and accept it. – Willem Mulder Dec 19 '19 at 9:31

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.