March 2019

Salesforce

How to get all the formula fields in Salesforce?

Apex Code: Map<String, Schema.SObjectType> globalMap = Schema.getGlobalDescribe();   for ( String key: globalMap.keySet() ) {          Map<String, Schema.SObjectField> fieldsMap = globalMap.get( key ).getDescribe().fields.getMap();       for ( String fieldKey: fieldsMap.keySet() ) {                  DescribeFieldResult dfr = fieldsMap.get( fieldKey ).getDescribe();           if ( dfr.isCalculated() ) {                          System.debug( key + ',' + dfr.getName() + ',' + dfr.getCalculatedFormula() );                          }                  }          }   1. Set the debug log level to DEBUG for ApexCode and System. ....

Salesforce

Simple Twilio SMS Handler for Salesforce

Remote Site Settings: Sample Code: public class TwilioSMSHandler {              public static void send( String strPhone ) {                  ErrorResponseWrapper erw;           String smsBody = 'Test Message';           String strMediaURL = 'IMAGE_URL_WITH_EXTENSION';                  final String fromNumber = 'FROM_NUMBER';            String account = 'ACCOUNT_SID';             String token = 'ACCESS_TOKEN';                  HttpRequest req = new HttpRequest();           req.setEndpoint( 'https://api.twilio.com/2010-04-01/Accounts/' + account + '/Messages' );           req.setMethod( 'POST' );            req.setHeader( 'Content-Type', 'application/x-www-form-urlencoded' );           Blob headerValue = Blob.valueOf( account + ':' + token );           String authorizationHeader = 'BASIC ' +           EncodingUtil.base64Encode( headerValue );           req.setHeader( 'Authorization', authorizationHeader );                      if ( strPhone != null ) {                  req.setBody( 'To=' + EncodingUtil.urlEncode( strPhone, 'UTF-8' ) + '&From=' + fromNumber + '&Body=' + smsBody + '&MediaUrl=' + strMediaURL );   ....