Skip to main content

Posts

Showing posts from April, 2019

Filter any report by current Logged In User in Salesforce | Salesforce Tutorials | Salesforce Development

Alert in Lightning Component

How to show Alerts in Lightning Component. So today we'll learn to use alerts in lightning component. In lightning component we have multiple alerts.
1.  Info Alerts



To use info alerts copy and paste below code in your component.
<divclass="slds-notify slds-notify_alert slds-theme_alert-texture slds-theme_info"role="alert"><spanclass="slds-assistive-text">info</span><spanclass="slds-icon_container slds-icon-utility-user slds-m-right_x-small"title="Description of icon when needed"><svgclass="slds-icon slds-icon_x-small"aria-hidden="true"><usexlink:href="/assets/icons/utility-sprite/svg/symbols.svg#user"></use></svg>

Modal Popup in Lightning Component Salesforce

How to display modal popup on button's click in Lightning Component ?  To display modal popup in your component first create a button in your Component which will be used to show & hide modal popup.  
1 2 3 4<lightning:button variant="brand" label="Click to Open" title="Click to Open" onclick="{!c.showModel}"/> After that lets add a boolean type attribute above button tag to storeTrue & False value.1<aura:attribute name="showModal" type="boolean"default="false"/>
Copy and paste below code after button in your component. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35<aura:if isTrue="{!v.showModal}"><section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby=…

Required field validation in Lightning Component.

How to apply required field validation in lightning component ? Lets learn it by an example. In my case I am having a <ui:input> name oppName and a lightning button in my lightning component.
To apply the validation we have to write code on click of lightning button.
Here is the code below : 
buttonClick : function(component){ var oppName = component.find("oppName");         if(oppValue == null){             oppName.set("v.errors",[{message:"You must enter a value"}]);         }         else{             oppName.set("v.errors", null);               } }
In this above example first I get my component in a variable oppName. After that I am checking that if its value is Null.
And if the value is null then I am setting the error message using v.error in set function.
Once the value if filled again than it is necessary to make error attribute null again in else part otherwise it will keep showing the error.
Share this post with your friends if this helps…