May 2019

Salesforce

Reusable Related List Lightning Component with filter in Salesforce

Sample Code: Apex Class: public class RelatedListController {              @AuraEnabled       public static RelatedListResult fetchRecs( String recId, String sObjName, String parentFldNam, String strCriteria ) {                      String strTitle = ' (';                    List < sObject > listsObjects = new List < sObject >();           RelatedListResult obj = new RelatedListResult();           String strSOQL = 'SELECT Id FROM ' + sObjName + ' WHERE ' + parentFldNam + ' = '' + recid + ''';           if ( String.isNotBlank( strCriteria ) )               strSOQL += ' ' + strCriteria;           strSOQL += ' LIMIT 4';           listsObjects = Database.query( strSOQL );             Integer intCount = listsObjects.size();           if ( intCount > 3 ) {                              List < sObject > tempListsObjects = new List < sObject >();               for ( Integer i = 0; i <3; i++ )                   tempListsObjects.add( listsObjects.get( i ) );                              obj.listsObject = tempListsObjects;               strTitle += '3+';   ....

Salesforce

How to get content from lightning:inputRichText without HTML Tags?

Sample Code: Lightning Component: <aura:component implements = "force:appHostable">              <aura:attribute name="myVal" type="String" />              <div class="slds-box slds-theme_default">                      <lightning:inputRichText value = "{!v.myVal}"/>           <lightning:button variant = "brand" label = "Show" onclick = "{! c.handleClick }"/>                  </div>          </aura:component>   Lightning Component Controller: ({              handleClick : function(component, event, helper) {                      var tempVal = component.get("v.myVal");           var tempDivElement = document.createElement("div");           tempDivElement.innerHTML = tempVal;           alert( "With HTML Tags " + tempVal );           tempVal = tempDivElement.textContent;           alert( "Without HTML Tags " + tempVal );              ....