+ Start a Discussion
KoolABKoolAB 

Record Lock is not released even after completion of apex transaction in lightning experience

0
I have created a custom lightning component to do mass update of Opportunity Lines. I have added that component as tab against the Opportunity. When i do mass update of Opportunity lines and it is finished successfully. I return to opportunity header detail page in the same session and try to edit the opportunity header fields and save the Opportunity. It throws error that edit is performed in the session please reload the page to update the opportunity header. Since mass update transaction is already complete lock should have been released I also have not locked explicitly inside my apex code. Does anybody know if this is known SFDC issue or how to fix this without refreshing the page
KoolABKoolAB
I am able to reproduce the issue in dev org as well. issue occurs if i do updates more than once in the same session without navigating to any other tab. If i hit mass update and lines are updated first time, i am able to update oppty header details but if i hit mass update button for second time i am unable to update oppty header without refreshing the page
KoolABKoolAB
Apex controller Server side
********************
public class LtngUpdateLines{

@AuraEnabled
public static void MassUpdateLines(Id recordId)
{
list<OpportunityLineItem> lstlines = new List<OpportunityLineItem>();
list<OpportunityLineItem> lines = [select Id,quantity from OpportunityLineItem where OpportunityId = :recordId];

if (lines.size() > 0)
{
    for (opportunityLineItem o1:lines)
    {
        o1.quantity = 888;
       lstlines.add(o1);
    }

    Database.SaveResult[] sv1 = Database.Update(lstlines,false);

}
}
}
 
Lightning component controller
({
    updateLines : function(component, event, helper) {
         var action = component.get('c.MassUpdateLines');

      // pass the apex method parameters to action 
      action.setParams({
         'recordId' : component.get("v.recordId")
      });
      action.setCallback(this, function(response) {
         //store state of response
         var state = response.getState();
         if (state === "SUCCESS") {
            //set response value in list of line items attribute on component.
           alert('Inside success');
         }
      });
      $A.enqueueAction(action);    
    }
})
 
<aura:component controller="LtngUpdateLines" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
	
    <head>
        <link href="/salesforce/assets/styles/salesforce-lightning-design-system.min.css" rel="stylesheet" type="text/css" />
</head>
<ui:button aura:id="button" buttonTitle="Mass Update Lines" class="button" label="Click me" press="{!c.updateLines}"/>