0

I am trying to update case status field on lightning detail page. We are not using case feed. I think lightning components cannot be added on case and Work Order detail page. FYI: Actions on Case object in Lightning

What is the best approach. when i try to add lightning button it shows on the case feed.But i need on detail page. Only approach i can think of is New Button or Link :URL or Visualforce Page Button I tried both. On click of the button, I need to update the status to "Completed". User should not refresh to reflect the change. Right now with this approach i need to refresh the page few times to reflect the changes.

Can someone please help.Also please let me know if there is any other approach. URL: /apex/UpdateCasePage?cid={!Case.Id}


<apex:page controller="CaseUpdStatus" action="{!updateCasestatus}">
    <apex:form >
        <apex:pageMessages ></apex:pageMessages>
    </apex:form> 
    <script type="text/javascript">
        function RefreshPrimaryTab() 
        {
                    window.close();
                  window.top.location.href = '/{!cid}' ;
        }
    </script>    
</apex:page>

Class:


public with sharing class CaseUpdStatus{
    public string cId {get;set;}
    // constructor
    public CaseUpdStatus(){
        cId = apexpages.currentpage().getparameters().get('cid');
    }
    public pagereference updateCasestatus(){        
        // getting case Record Details
        List<case> lstCase = [SELECT ID,
                                        RecordType.Name,
                                        status
                                    FROM case
                                    WHERE ID =:cId];
        system.debug('\n--lstCase--'+lstCase);
        if(!lstCase.isEmpty()){                           
                lstCase[0].status= 'Completed';
                update lstCase;
                pagereference page = new Pagereference('/'+cId);
                page.setRedirect(true);
                return page;                                      
        }
        return null;             
    }
} 
  • I tried this vfpage and controller to do this. Values are not refreshing – VSFDC Nov 10 '17 at 21:51
  • Can you edit the code of the page and controller into your question? – JaredT Nov 10 '17 at 21:53
  • the <script> tags and what is between are completely unnecessary; the VF pageaction method will redirect to the Case detail page if successful ; if an error, you should use ApexPage.addMessage(...) to get the error to appear – cropredy Nov 10 '17 at 23:32
0

@VSDF,

Yes, quick actions appear on feed layout for case and work order object. To solve this problem follow below steps:

  1. Create custom component with the button as close case.

  2. Get the record Id, pass it to the lightning controller and close the case, you can use lightning data service too.

  3. On successful update you can fire $A.get("e.force:refreshView").fire(); to refresh the detail page without reloading the entire page.

  • When you add button with Lightning Component behind on case is not displaying on layout – VSFDC Nov 14 '17 at 21:37
  • @VSFDC What do you mean by behind the case. You should add the new component which will have some buttons on the lightning app builder record page itself. – Kiran Machhewar Nov 16 '17 at 8:20

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.