I have a VF page that I use for both classic and lightning. In this page, there is a button to create a new account. For classic, it just redirects the page to this url:
/001/e?setup/ui/recordtypeselect.jsp?ent=Account
For lightning, this takes the user to the account create page, but it skips the record type selection. So it tries to create an account with no record type, and it errors out.
Any thoughts on how I can create a link to the new account page with a record type picker (if needed) that would work for both classic and lightning?
Thanks
update: if it helps, here's a quick snippet of code. the button itself is just a SLDS styled button
<button class="slds-button slds-button--neutral" onclick="gotoNewAccountPage()">
<svg class="slds-button__icon slds-button__icon--left" aria-hidden="true">
<use xlink:href="{!URLFOR($Asset.SLDS, '/assets/icons/utility-sprite/svg/symbols.svg#new')}" />
</svg>
New Account
</button>
then it does this on click
function navigateToUrl(url){
if(isLightningDesktop()){
sforce.one.navigateToURL(url, true);
// sforce.one.createRecord("Account", "012***************")
}else{
window.location.href = url;
}
}
function gotoNewAccountPage(){
navigateToUrl("/001/e?setup/ui/recordtypeselect.jsp?ent=Account");
}
as you guys can see commented out on the navigateToUrl method, the createRecord would work well if I had a record type id. but in this case, I do not since the user has to pick something first
sforce.one
object, which gives you some methods to navigate within the platform. One of them iscreateRecord
that can receive the developer name of the object to create and its record type. The record type is optional, so I believe the platform should prompt you with the record type selection page. Take a look at the docs (developer.salesforce.com/docs/atlas.en-us.salesforce1.meta/…).