Tuesday, July 9, 2019

playing with force:inputField - addressing rendering issue and hiding new option from the look up drop down

As we know we do have a limitation on lookup fields in lightning components and if we don't want to go for custom component force:inputFueld is one option.

We have 2 very core limitation on that 

1. Conditional rendering of the field 
2. Hiding the new action

To resolve the #1 wrap force:inputField with <aura:renderIf > instead of aura:if so that revaluation of the rendering logic happen again


To address #2 we need a CSS trick, please add below CSS to your component to hide the New Record option as it does not obey the action override. 

.THIS.createNew{
    display : none !important;
}

Thursday, May 23, 2019

force:showToast Message Display In Multiple Lines In Salesforce Lightning Component

force:showToast Message Display In Multiple Lines In Salesforce Lightning Component


Dear Devs,

Today in this post I am going to share a workaround for salesforce lightning force:showToast event to display toast message in multiple lines. without any custom code. 


I will be using the power of aura:html tag to do that append this to your lightning component 

<aura:html tag="style">.toastMessage.forceActionsText{
white-space : pre-line !important;
}</aura:html>
Add this to your helper js file.
showToast: function (message) {
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"title": "Action not allowed!",
"message": message,
"type" : "error",
"mode" : "sticky"
});
toastEvent.fire();
},

Not the controller or any other helper method invoke the show mesage method
myfun : function(component,event,helper){
var errMessage = "This is my first error message. \n" ;
errMessage += "This is my senond error message. \n" ;
errMessage += "This is my third error message. \n" ;
helper.showToast(errMessage);
}
The message will appar like above and no custom component is needed to achive that.
Hope this will save your time



Tips on passing Salesforce AI Associate Certification

  🌟 Motivation to Pursue the Salesforce AI Associate Certification 🌟 The world of technology is in a state of perpetual evolution, and on...