+ Start a Discussion
Shravan SazawalShravan Sazawal 

Lightning component - Custom Action on a Custom object- Create new Case record


I have a custom button/action of Action Type lightning component on a custom object that, when clicked, automatically creates a new case record of a certain Record Type, if it isn't linked to an existing case. The requirement is- to avoid automatically creating a case record, and instead give the user an option to manually choose the record type from a pop-up, similar to creating a new case from the Case object itself and then chossing a record type. I'm not too familiar with Lightning dev and would highly appreciate any assistance.

Below is the JS controller code:
({
      CreateCase : function(component, event, helper) {
      
        var caseNumberAdd3 = component.get("c.CasenumberShopp");
       var caseDetails=[];
          var caseid;
        caseNumberAdd3.setParams({
            "shoppingactivityID" :component.get("v.recordId")
        });
           caseNumberAdd3.setCallback(this, function(response){
              
              if(response.getState()==="SUCCESS")
                {
                caseDetails=response.getReturnValue();
                   document.getElementById('loader1').style.display = 'none';
                    if(caseDetails===null){
                        document.getElementById('mainDiv44').style.display = 'block';
                                  
                    }
                    else{
                           $.each(caseDetails, function(key, value){
                   
                    if(key==="Id")
                    {
                        caseid=value;
                        var urlEvent = $A.get("e.force:navigateToURL");
            urlEvent.setParams({
                "url": '/'+ value
                //component.get("v.caseid")
            });
            urlEvent.fire();
                        
                    }
                });
                        
                    }
                         
                }
               });
 $A.enqueueAction(caseNumberAdd3);
            
    },close:function(component, event, helper) {
        document.getElementById("successMsg").style.display = 'none';
    }   
})
Anil SomasundaranAnil Somasundaran
Hi Shravan Sazawal,

Do you still have this requirement ?
Shravan SazawalShravan Sazawal
I ended up going a different route to solve this and would like to delete this post, but apparently I can't delete my own post(not particularly a fan of such a feature)