I am facing below issue ,while prepopulating some field values in a quick action(alternate of URL hacking in classic) Unable to redirect to Record detail page ,which is created on saving quick action( which is being called from extension controller of VF page using QuickAction.QuickActionRequest class) Please suggest if anyone has implemented the same.\ Please find the code as below: VF page:
<apex:page standardcontroller="Account" extensions="QuickActionRequestContact">
<apex:includeLightning />
<script>
$Lightning.use("c:QuickActionReqest",function(){
$Lightning.createComponent("c:NavigationPageref",
{},
"mycon",
function(cmp)
{
console.log("Inside lightning out");
alert("Inside ltng:out");
cmp.set("v.recordId","{!Account.id}");
});
});
</script>
<apex:form>
<apex:pageblock title="createContact" >
<apex:pageblocksection>
<apex:commandButton value="createContact" action="{!createContact}" Rerender="mycon"/>
</apex:pageblocksection>
</apex:pageblock>
</apex:form>
</apex:page>
Application:
<aura:application access="GLOBAL" extends="ltng:outApp" >
<aura:dependency resource="c:NavigationPageref"/>
</aura:application>
controller:
public class QuickActionRequestContact
{
ApexPages.StandardController ctrl;
Account acc;
public QuickActionRequestContact(ApexPages.StandardController c) // Extension constructor
{
ctrl = c;
acc = (Account)c.getRecord();
}
public static pagereference createContact()
{
String myRecId = ApexPages.currentPage().getParameters().get('Id');
QuickAction.QuickActionRequest req = new QuickAction.QuickActionRequest();
// Some quick action name
req.quickActionName = Schema.Account.QuickAction.Create_Contact_Standard;
// Define a record for the quick action to create
Contact c = new Contact();
c.lastname = 'last name';
req.record = c;
// Provide the context ID (or parent ID). In this case, it is an Account record.
req.contextid = myRecId;
QuickAction.QuickActionResult res = QuickAction.performQuickAction(req);
system.debug('result'+res.getIds());
system.debug('result'+res);
return null;
}
}
Navigation component:
<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId">
<aura:attribute name="recordId" type="String"/>
<aura:attribute name="url" type="String"/>
Welcome to Navigation
<aura:handler name="init" value="{!this}" action="{!c.goToRec}"/>
<lightning:navigation aura:id="navLink"/>
<aura:component>
controller.js:
{(
goToRec : function(component, event, helper) {
var navLink = component.find("navLink");
var pageRef = {
type: 'standard__recordPage',
attributes: {
actionName: 'view',
objectApiName: 'Contact',
},
};
navLink.navigate(pageRef, true);
}
})