0

I have a custom object with two different record types assigned to the standard user profile. We are using a Lightning Component to override the standard functionality of the New button, and this lightning component launches a e.force:createRecord event after the user clicks some checkboxes to agree to various terms and agreements.

Our problem is this. Overriding the new component doesn't seem to override the standard pop-up that asks the user what recordType they'd like to create. This would be fine, but I can't figure out how to access which recordType they've chosen in order to populate the e.force:createRecord event with the appropriate recordTypeId. Because I can't get the standard pop-up to disappear, I can't just ask them to select the recordType they'd like to create in my lightning component since then they are being asked to choose the recordType twice, once by salesforce and then again by my component. And finally, if I make the standard pop-up go away by unassining one of the recordTypes from the user profile so that it defaults to one and THEN I allow them to pick the recordType in my component, I can correctly fire the e.force:createRecord event for either recordType, but when they go to save the record I get an error stating that the recordType is not available for that user (because it isn't). This means that they cannot submit a record of type they aren't assigned to though they can fill out the creation form.

I am at a loss for what to do here. The only thing that seems like it would make sense is if there was a way to tell which recordType the user chose before the lightning component override happens, but I have not been able to find a way to access that choice from my lightning component.

Any help or thoughts would be appreciated, thanks.

  • There is a method called isAvailable which can be used on record types fetched using getDescribe for any object. isAvailabe returns True if that record type is available for that user. So, you can only show the record types with isAvailable as true which succesfully saves the record. developer.salesforce.com/docs/atlas.en-us.apexcode.meta/… – Nihar Oct 10 '17 at 17:16
  • Hey, thanks for the reply. If I am checking which recordTypes are available, that doesn't seem to fix my problem, since that leaves me with still needing to enable both types, which then has the user having to select the recrordTypes twice, once on the standard salesforce pop-up (which does nothing) and once on my lightning component. Unless I am missing something, which is very possible. Thanks! – Tylor Lilley Oct 10 '17 at 17:18
  • Yup, you will still have both the pop ups showing up, I have not worked on scenario of overriding new button. But I had a scenario where I had to show recordtypes based on object type. I have used this kind of logic to show available record types for a user. This alternative helps restrict user from selecting only one of the record types assigned to them so that the Save record can be successfull.(as they can be only able to select record types available to them.) This does not completely solve the problem.I think there will be better alternatives. – Nihar Oct 10 '17 at 17:29
  • there must be an option while overriding the new button. I am not sure about lightning but in classic, there is a checkbox which asks if record type page should be displayed or not. – Ashish Sharma Oct 10 '17 at 17:35
  • Similar question. This might help a bit. There is an option to skip the recordtypes screen when doing the override. As per the discussion , this was not working in previous release but has been fixed in Winter 18. Please check this question. salesforce.stackexchange.com/questions/185589/… – Nihar Oct 10 '17 at 17:37
3

Please look for the checkbox highlighted in attached image Skip record type selection page. Refer this image

This way, you can stop the first standard popup hidden. For record type selection, you can write another component which will query available record types. From custom record type selection component, you can pass selected record type id to new account custom component.

Hope this helps you.

  • Fantastic, thank you! I knew I had to be missing something somewhere as there seemed to be no good way to use button overrides with different recordTypes otherwise. Thanks again! – Tylor Lilley Oct 10 '17 at 17:52
  • I'm Glad it helped. – Ashish Sharma Oct 10 '17 at 17:53
0

There is a better way to do this now. Please checkout my answer in this post

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.