10

I have Visualforce Page which redirects to standard accounts edit page with prepoulated value for record Type. The record type is getting populated using URL hack. But since URL hacks dont work in lightning experience this functionality is not working and the record type is not populated.

Is there any other workaround to redirect to a standard page with pre-poulated values in Lightning?

1
  • No in Lightning standard page you can't pre-populate value using url hack..
    – Ratan Paul
    Apr 8, 2016 at 13:41

2 Answers 2

5

First you create a lightning Application name myFirstApp which retrieve data from the url. if your URl is like this /c/ChooseCampaignApp.app?AccountId=001P000000eM5z7&ContactId=003P000000hlONG

Then the attribute name must be same as the the Url which contains the values myFirstApp.app

<aura:application>
<aura:attribute name=”AccountId” type=”String”/>
  Value in AccountId Attribute: {!v.AccountId}
<c:AccountByID accGetID=”{!v.AccountId}”/>

Create a component Name: AccountFormByID, adding a server-side controller, AccountFormByIDController, with an attribute: accGetID

<aura:component controller=”AccountFormByIDController” >
    <aura:attribute name=”accGetID” type=”String”/> 
    <aura:attribute name=”ac” type=”Account”/>   
    <aura:handler name=”init” value=”{!this}” action=”{!c.doInitAction}” />
    <ui:inputText label=”Account Name” value=”{!v.ac.Name}”/>
    <ui:inputText label=”Type” value=”{!v.ac.Type}”/> 
    <ui:inputText label=”Industry” value=”{!v.ac.Industry}”/>  
</aura:component>

Client-side Controller:

    ({
    doInitAction : function(component, event, helper) {
              var action = component.get(“c.find_AccById”);
        action.setParams({ “get_accountid”: component.get(“v.accGetID”) });
         action.setCallback( this, function(response) {
            var state = response.getState();
            if (state === “SUCCESS”) {
                component.set(“v.ac”, response.getReturnValue());
                console.log(response.getReturnValue());
            }
        });
        $A.enqueueAction(action);
    },
})

Server side Controller:-

    public class AccountFormByIDController {
    @AuraEnabled
    public static Account find_AccById(Id get_accountid) {
        if(get_accountid != null ) {
            return [SELECT Id, Name, Type, Industry from Account where ID = :get_accountid];
        }
        else{
            return [SELECT ID,  Name, Type, Industry from Account LIMIT 1];
        }     
    }

}
4

Option 1

If possible, you may consider reverting back to Salesforce Classic until (or if) Lightning Experience supports your needed features. It's not a complete product yet but is getting new features each release. In the release notes there's usually a section about what new is supported but also what isn't yet.

Option 2

Try using Chatter Quick Actions that can pre-populate values for you. For creating Accounts this may need to be a Global Action, but for Contacts and Opportunities those can be object-specific and available from their parent account page.

Option 3

Have your custom button URL point to a Flow. You can use its screen wizard to prompt for fields, have fields pre-populated, etc. if you embed the Flow in Visualforce page then on complete you can redirect the user to the newly created record.

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.