You need to sign in to do that
Don't have an account?
sunil Pal 13
Call edit action from lightning component
Hi All,
I am trying to call Account action Lets say Edit from Lightning component. I have used qucik Action API but always its gives me error:
"The action you specified isn’t available on the current record page". I Edit button is on page layout as well.
My code is below:
Component:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" extends="c:base">
<aura:attribute name="acc" type="Account"/>
<aura:attribute name="recordId" type="String"/>
<force:recordData aura:id="recordLoader"
recordId="{!v.recordId}"
fields="Id, Name"
targetFields="{!v.acc}"
targetError="{!v.recordLoadError}"
/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<lightning:quickActionAPI aura:id="quickActionAPI" />
<div class="slds-page-header">
<lightning:buttonGroup>
<lightning:button variant="neutral" label="Check for New Data" onclick="{!c.checkNewData}"/>
</lightning:buttonGroup>
</div>
</aura:component>
Controller:
({
doInit : function(component, event, helper) {
},
checkNewData: function(component, event, helper) {
console.log('**test**'+component.get("v.recordId"));
var actionAPI = component.find("quickActionAPI");
var fields = {Id: {value: component.get("v.recordId")}};
var args = { actionName : "Account.Edit",
entityName : "Account",
targetFields : fields };
console.log('**args**'+args);
console.log('**args1**',args.toString());
actionAPI.setActionFieldValues(args).then(function() {
actionAPI.invokeAction(args);
}).catch(function(e){
if(e.errors){
console.log('Action Field Log Errors are ',e.errors);
console.error('Full error is ', JSON.stringify(e));
}
});
}
})
Please let me know If am doing anything wrong.
Looking for suggestion.
Thank you in Advance.
I am trying to call Account action Lets say Edit from Lightning component. I have used qucik Action API but always its gives me error:
"The action you specified isn’t available on the current record page". I Edit button is on page layout as well.
My code is below:
Component:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" extends="c:base">
<aura:attribute name="acc" type="Account"/>
<aura:attribute name="recordId" type="String"/>
<force:recordData aura:id="recordLoader"
recordId="{!v.recordId}"
fields="Id, Name"
targetFields="{!v.acc}"
targetError="{!v.recordLoadError}"
/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<lightning:quickActionAPI aura:id="quickActionAPI" />
<div class="slds-page-header">
<lightning:buttonGroup>
<lightning:button variant="neutral" label="Check for New Data" onclick="{!c.checkNewData}"/>
</lightning:buttonGroup>
</div>
</aura:component>
Controller:
({
doInit : function(component, event, helper) {
},
checkNewData: function(component, event, helper) {
console.log('**test**'+component.get("v.recordId"));
var actionAPI = component.find("quickActionAPI");
var fields = {Id: {value: component.get("v.recordId")}};
var args = { actionName : "Account.Edit",
entityName : "Account",
targetFields : fields };
console.log('**args**'+args);
console.log('**args1**',args.toString());
actionAPI.setActionFieldValues(args).then(function() {
actionAPI.invokeAction(args);
}).catch(function(e){
if(e.errors){
console.log('Action Field Log Errors are ',e.errors);
console.error('Full error is ', JSON.stringify(e));
}
});
}
})
Please let me know If am doing anything wrong.
Looking for suggestion.
Thank you in Advance.
I found a developer page where in they described a way to write a edit action please find the link below for your reference:
>> https://developer.salesforce.com/forums/?id=9060G000000MW5gQAG
In case if you find this useful can you please close the thread after making this best answer so that it can be used by others in the future and also helps in keeping our community clean.
Regards,
Anutej
But thank you for your response.