Salesforce

Salesforce

How to find Right of string in Lightning Component Controller?

Sample Code: Lightning Component: <aura:component implements = "force:appHostable">                <aura:attribute name = "str" type = "String"/>              <aura:handler name = "init" value = "{!this}" action = "{!c.onInit}"/>              <div class = "slds-box slds-theme_default">                   String is {! v.str }                  </div>            </aura:component>   Lightning Controller: ({                onInit : function( component, event, helper ) {                        var temp = 'testing';           var tmp = temp.substr( -2 );           component.set( "v.str", tmp );                  }          })   ....

Salesforce

How to update Sub Query data in Lightning Component JavaScript Controller?

In the below example, I have updated the contact name to 'Testing'. Sample code: Lightning component: <aura:component implements = "force:appHostable"                   controller = "AccountListController">                <aura:attribute type = "object[]" name = "acctList"/>                <aura:handler name = "init" value = "{!this}" action = "{!c.onInit}"/>              <div class = "slds-box slds-theme_default">               <aura:iteration items = "{! v.acctList }" var = "acc">                               Account Name - {! acc.Name }<br/>                              <aura:iteration items = "{! acc.Contacts }" var = "con">    ....

Salesforce

How to get all Email Fields in Salesforce?

Sample Code:     Set < String > listsObjs = new Set < String > {'Account', 'Lead'};       Map<String, Schema.SObjectType > globalDescription = Schema.getGlobalDescribe();             for ( String obj : listsObjs ) {          Schema.sObjectType objType = globalDescription.get( obj );       Schema.DescribeSObjectResult r1 = objType.getDescribe();        Map<String , Schema.SObjectField > mapFieldList = r1.fields.getMap();            for ( Schema.SObjectField field : mapFieldList.values() ) {                    Schema.DescribeFieldResult fieldResult = field.getDescribe();             String fieldLabel = fieldResult.getLabel().toLowerCase();           Schema.DisplayType fielddataType = fieldResult.getType();              if ( fielddataType == Schema.DisplayType.Email ) {                          System.debug( objType + '.' + fieldResult.getName() );                          }  else if ( fieldLabel.contains( 'email' ) && ! fieldResult.isCalculated() ) {                          System.debug ( objType + '.' + fieldResult.getName() );                      }   ....

Salesforce

How to get all First Name and Last Name Fields in Salesforce?

Sample Code: Set < String > listsObjs = new Set < String > {'Account', 'Lead'};       Map<String, Schema.SObjectType > globalDescription = Schema.getGlobalDescribe();             for ( String obj : listsObjs ) {          Schema.sObjectType objType = globalDescription.get( obj );       Schema.DescribeSObjectResult r1 = objType.getDescribe();        Map<String , Schema.SObjectField > mapFieldList = r1.fields.getMap();            for ( Schema.SObjectField field : mapFieldList.values() ) {                    Schema.DescribeFieldResult fieldResult = field.getDescribe();             String fieldLabel = fieldResult.getLabel().toLowerCase();           Schema.DisplayType fielddataType = fieldResult.getType();              if ( ( fieldLabel.contains( 'first name' ) || fieldLabel.contains( 'last name' )                  || fieldLabel.contains( 'firstname' ) || fieldLabel.contains( 'lastname' ) )                && ! fieldResult.isCalculated() ) {                          System.debug ( objType + '.' + fieldResult.getName() );                      }                  }          }   In the ....