function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Peter BölkePeter Bölke 

Open Lightning Modal Cases

Hello,

i need to have a button on case object which opens a lightning modal to enter some information. As i understand that isnt easy with the case object.

Does anybody know how to get something like this working?
User-added image

thanks
Peter
Best Answer chosen by Peter Bölke
Harshitha BHarshitha B
Hi Peter,
Please refer the below code, it may be help for you.

Case_Model.cmp
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global">
    <!--use boolean attribute for Store true/false value,
    make default to "false" so modal box are not display on the load of component. 
    --> 
    <aura:attribute name="isOpen" type="boolean" default="false"/>
    
    <!--Use "slds-m-around_xx-large" class to add standard X-Large padding to the component--> 
    <div class="slds-m-around_xx-large">
        
        <lightning:button variant="brand"
                          label="Case Model"
                          title="Case Model"
                          onclick="{! c.openModel }" />
        <!--Use aura:if tag to display Model Box, on the bese of conditions. [isOpen boolean attribute] -->   
        <aura:if isTrue="{!v.isOpen}">
            
            <!--###### MODAL BOX Start######--> 
            <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
                <div class="slds-modal__container">
                    <!-- ###### MODAL BOX HEADER Start ######-->
                    <header class="slds-modal__header">
                        <lightning:buttonIcon iconName="utility:close"
                                              onclick="{! c.closeModel }"
                                              alternativeText="close"
                                              variant="bare-inverse"
                                              class="slds-modal__close"/>
                        <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Case Information Details</h2>
                    </header>
                    <!--###### MODAL BOX BODY Part Start######-->
                    <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
                        <p><b>
                            <!-- Calling Other Component -->   
                            <c:Lightning_Input_Component/>
                            </b>
                        </p>
                    </div>
                    <!--###### MODAL BOX FOOTER Part Start ######-->
                    <footer class="slds-modal__footer">
                        <lightning:button variant="neutral" 
                                          label="Cancel"
                                          title="Cancel"
                                          onclick="{! c.closeModel }"/>
                        <lightning:button variant="brand" 
                                          label="Save"
                                          title="Save"
                                          onclick="{! c.Save }"/>
                    </footer>
                </div>
            </section>
            <div class="slds-backdrop slds-backdrop_open"></div>
            <!--###### MODAL BOX Part END Here ######-->
            
        </aura:if>
    </div>
</aura:component>
Case_ModelController.js
({
   openModel: function(component, event, helper) {
      // for Display Model,set the "isOpen" attribute to "true"
      component.set("v.isOpen", true);
   },
 
   closeModel: function(component, event, helper) {
      // for Hide/Close Model,set the "isOpen" attribute to "Fasle"  
      component.set("v.isOpen", false);
   },
 
   Save: function(component, event, helper) {
      // and set set the "isOpen" attribute to "False for close the model Box.
      component.set("v.isOpen", false);
   },
})
Lightning_Input_Component.cmp
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <div class="row">
     <lightning:textarea name="input3" label="Case Reason" placeholder="Enter Case reason details"/>
  </div>
	
</aura:component>
Output:
User-added image
User-added image







 

All Answers

Ravi Dutt SharmaRavi Dutt Sharma
You need to create a lightning component which opens up like a modal. You can use below example as a reference:

https://www.lightningdesignsystem.com/components/modals/
 
Maharajan CMaharajan C
Hi Peter,

Please refer the below with great examples.

just use boolean attribute to open the modal and close on click the button. The Modal have to be designed by SLDS.

http://sfdcmonkey.com/2017/04/15/modal-box-lightning-component-salesforce/


without using SLDS: using lightningoverlay

http://biswajeetsamal.com/blog/lightning-overlaylibrary-modal/
http://www.salesforcenextgen.com/how-to-create-a-modal-box-in-lightning-component/
https://rajvakati.com/2018/05/29/lightningoverlaylibrary-example/

 Can you please Let me know if it helps or not!!!

If it helps don't forget to mark this as a best answer!!!

Thanks,
Raj
Harshitha BHarshitha B
Hi Peter,
Please refer the below code, it may be help for you.

Case_Model.cmp
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global">
    <!--use boolean attribute for Store true/false value,
    make default to "false" so modal box are not display on the load of component. 
    --> 
    <aura:attribute name="isOpen" type="boolean" default="false"/>
    
    <!--Use "slds-m-around_xx-large" class to add standard X-Large padding to the component--> 
    <div class="slds-m-around_xx-large">
        
        <lightning:button variant="brand"
                          label="Case Model"
                          title="Case Model"
                          onclick="{! c.openModel }" />
        <!--Use aura:if tag to display Model Box, on the bese of conditions. [isOpen boolean attribute] -->   
        <aura:if isTrue="{!v.isOpen}">
            
            <!--###### MODAL BOX Start######--> 
            <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
                <div class="slds-modal__container">
                    <!-- ###### MODAL BOX HEADER Start ######-->
                    <header class="slds-modal__header">
                        <lightning:buttonIcon iconName="utility:close"
                                              onclick="{! c.closeModel }"
                                              alternativeText="close"
                                              variant="bare-inverse"
                                              class="slds-modal__close"/>
                        <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Case Information Details</h2>
                    </header>
                    <!--###### MODAL BOX BODY Part Start######-->
                    <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
                        <p><b>
                            <!-- Calling Other Component -->   
                            <c:Lightning_Input_Component/>
                            </b>
                        </p>
                    </div>
                    <!--###### MODAL BOX FOOTER Part Start ######-->
                    <footer class="slds-modal__footer">
                        <lightning:button variant="neutral" 
                                          label="Cancel"
                                          title="Cancel"
                                          onclick="{! c.closeModel }"/>
                        <lightning:button variant="brand" 
                                          label="Save"
                                          title="Save"
                                          onclick="{! c.Save }"/>
                    </footer>
                </div>
            </section>
            <div class="slds-backdrop slds-backdrop_open"></div>
            <!--###### MODAL BOX Part END Here ######-->
            
        </aura:if>
    </div>
</aura:component>
Case_ModelController.js
({
   openModel: function(component, event, helper) {
      // for Display Model,set the "isOpen" attribute to "true"
      component.set("v.isOpen", true);
   },
 
   closeModel: function(component, event, helper) {
      // for Hide/Close Model,set the "isOpen" attribute to "Fasle"  
      component.set("v.isOpen", false);
   },
 
   Save: function(component, event, helper) {
      // and set set the "isOpen" attribute to "False for close the model Box.
      component.set("v.isOpen", false);
   },
})
Lightning_Input_Component.cmp
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <div class="row">
     <lightning:textarea name="input3" label="Case Reason" placeholder="Enter Case reason details"/>
  </div>
	
</aura:component>
Output:
User-added image
User-added image







 
This was selected as the best answer