You need to sign in to do that
Don't have an account?
Eric Blaxton 11
display modal popup IF account status Else create new record
Hi and thank in advance.
We are migrating to lightning and i have a few javascript buttons to convert.
Js button "if("{!Account.Account_Status__c}"!="Active Account")
window.alert("You can create an RTO for an active Distributor only.");
else{
window.open
//prepopulate fields.
}"
I created an Aura Component to display a Modal popup. What I want to do is have an if / else statement
User clicks on Action: New Child record. If the Account status != Active, display Modal "you can only create child record on Active account.
If the Account status = Active then proceed with creating a new record. Then prepopulate some values on the new record.
Component
<aura:component implements="force:lightningQuickAction" >
<!--Boolean attribute to indicate if modal is open or not
default value is false as modal is closed when page is loaded
-->
<aura:attribute name="isModalOpen" type="boolean" default="false"/>
<!--Display modal based on Account status. If not active, display. Else prepopulate fields
-->
<aura:attribute name="recordId" type="Id" />
<aura:attribute name = "Account_Status__c" type="String"/>
<aura:attribute name="passThroughValue" type="String"/>
<lightning:card title="{!v.passThroughValue}">
</lightning:card>
<div class="slds-m-around_xx-large">
<div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
<p><b>
You can create an RTO for an active Distributor only.
</b>
</p>
</div>
<!--Use aura:if tag to display/hide popup based on isModalOpen value-->
<aura:if isTrue="{!v.Account_Status__c}">
<aura:if isTrue="{!v.isModalOpen}">
<!-- Modal/Popup Box starts here-->
<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/Popup Box Header Starts here-->
<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">Modal/PopUp Box</h2>
</header>
</div>
</section>
<div class="slds-backdrop slds-backdrop_open"></div>
</aura:if>
</aura:if>
</div>
</aura:component>
Controller:
({
openModel: function(component, event, helper) {
// Set isModalOpen attribute to true
component.set("v.isModalOpen", true);
},
closeModel: function(component, event, helper) {
// Set isModalOpen attribute to false
component.set("v.isModalOpen", false);
},
submitDetails: function(component, event, helper) {
// Set isModalOpen attribute to false
//Add your code to call apex method or do some processing
component.set("v.isModalOpen", false);
},
} )
Is this possible?
We are migrating to lightning and i have a few javascript buttons to convert.
Js button "if("{!Account.Account_Status__c}"!="Active Account")
window.alert("You can create an RTO for an active Distributor only.");
else{
window.open
//prepopulate fields.
}"
I created an Aura Component to display a Modal popup. What I want to do is have an if / else statement
User clicks on Action: New Child record. If the Account status != Active, display Modal "you can only create child record on Active account.
If the Account status = Active then proceed with creating a new record. Then prepopulate some values on the new record.
Component
<aura:component implements="force:lightningQuickAction" >
<!--Boolean attribute to indicate if modal is open or not
default value is false as modal is closed when page is loaded
-->
<aura:attribute name="isModalOpen" type="boolean" default="false"/>
<!--Display modal based on Account status. If not active, display. Else prepopulate fields
-->
<aura:attribute name="recordId" type="Id" />
<aura:attribute name = "Account_Status__c" type="String"/>
<aura:attribute name="passThroughValue" type="String"/>
<lightning:card title="{!v.passThroughValue}">
</lightning:card>
<div class="slds-m-around_xx-large">
<div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
<p><b>
You can create an RTO for an active Distributor only.
</b>
</p>
</div>
<!--Use aura:if tag to display/hide popup based on isModalOpen value-->
<aura:if isTrue="{!v.Account_Status__c}">
<aura:if isTrue="{!v.isModalOpen}">
<!-- Modal/Popup Box starts here-->
<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/Popup Box Header Starts here-->
<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">Modal/PopUp Box</h2>
</header>
</div>
</section>
<div class="slds-backdrop slds-backdrop_open"></div>
</aura:if>
</aura:if>
</div>
</aura:component>
Controller:
({
openModel: function(component, event, helper) {
// Set isModalOpen attribute to true
component.set("v.isModalOpen", true);
},
closeModel: function(component, event, helper) {
// Set isModalOpen attribute to false
component.set("v.isModalOpen", false);
},
submitDetails: function(component, event, helper) {
// Set isModalOpen attribute to false
//Add your code to call apex method or do some processing
component.set("v.isModalOpen", false);
},
} )
Is this possible?
i don't understand why you get modal no matter what. It us controlled by isModalOpen attribute and I can see it assign value true or false at different button click method.
You may take a look of lighting design system for modal.
https://www.lightningdesignsystem.com/components/modals/
All Answers
<aura:if isTrue="{!v.Account_Status__c}"><aura:if isTrue="{!v.isModalOpen}">
<header>
.......................
</header>
<aura:if isTrue="{!v.Account_Status__c != 'Active Account'}">
//display " you can only create child record on Active account. "
</aura:if>
<aura:if isTrue="{!v.Account_Status__c == 'Active Account'}">
<lightning:recordViewForm .... > // display record, you may use different component
..................
</lightning:recordViewForm >
</aura:if>
</aura:if> //isModalOpen
I made those adjustments and the modal displays no matter what. My goal is the following. Is the component / Action the best way to go about this?
Eric
i don't understand why you get modal no matter what. It us controlled by isModalOpen attribute and I can see it assign value true or false at different button click method.
You may take a look of lighting design system for modal.
https://www.lightningdesignsystem.com/components/modals/
Appreciate your time on this. I still can't get this to work. I might have to scrap it and start over.
Regards,
Eric