Thanks Edel", "answerCount": 1, "upvoteCount": 0, "datePublished": "2017-06-20T14:15:37.000Z", "author": { "@type": "Person", "name": "Edel Scannell", "url": "https://trailblazers.salesforce.com/profileView?u=00530000003qK8nAAE", "affiliation": { "@type": "Organization", "name": "Kerry" } }, "suggestedAnswer": [ { "@type": "Answer", "text": "parent.location.href doesn't work in lightning. Try using force:createRecord   ", "upvoteCount": 0, "url": "https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007T4E0XSAV", "datePublished": "2017-07-06T21:43:01.000Z", "author": { "@type": "Person", "name": "Suraj Pillai", "url": "https://trailblazers.salesforce.com/profileView?u=00530000009653FAAQ", "affiliation": { "@type": "Organization", "name": "Vertex Computer Systems Inc" } } } ] } } Skip to main content
We are currently looking at upgrading to Lightning for some of our user base. We have overwritten several of the standard new button with VF pages due to customisation we have completed in our org. Depending on the record types users have access they are routed to various record creat pages. Below is an example of what we have done for account creation. For the majority of our users we want to route them to a custom VF page before they get to the standard account edit page but for others we want to route them directly to the standard account edit page. We have used Javascript for this but when lightning is enabled the functionality doesnt work for our subset of users who we want to route to the standard edit page. On clicking the new button the code appears to get stuck in a loop. Any thoughts on what we are missing.

<apex:page standardController="Account"> 

<apex:includeScript value="/support/console/26.0/integration.js"/>

    <script>

    var url = '';

    if({!Account.RecordTypeId != "0120q0000004IdB"} && ({!$User.ProfileId != "00e0q000000LryaAAC"} || {!Account.RecordTypeId != null})){ <!-- Brands Account Record Type-->

        url = '/apex/accountDimensionSelectionPage?RecordType={!$CurrentPage.parameters.RecordType}';

    }else{

        url ='/001/e?ent=Account&RecordType={!$CurrentPage.parameters.RecordType}&CF00N80000004Wugx=.Distributor[No Hierarchy]&nooverride=0';

    }

    parent.location.href=url;

</script> 

</apex:page>

Thanks

Edel
1 respuesta
  1. 6 jul 2017, 21:43
    parent.location.href doesn't work in lightning. Try using force:createRecord

     

    <script>

    if($User.UIThemeDisplayed == 'Theme4d'){ //this is lightning

        var createRecordEvent = $A.get("e.force:createRecord");

        createRecordEvent.setParams({

            "entityApiName": "Contact"

        });

        createRecordEvent.fire();

    }else{

    //classic logic here

    }

    </script>