Wednesday, 30 November 2016

How to determine the string type (Numeric, AlphaNumeric, etc.) in Salesforce

Introduction

Salesforce provides new string methods to determine what type of characters contains in a particular string by using some of the below methods.

Methods to Determine Character Types

Alpha

  1. String str = 'AlphaOnly';
  2. System.assertEquals(true, str.isAlpha());

The above string method will return true, if the string contain only characters.

isAlphaSpace

  1. String str = 'AlphaOnly Space';
  2. System.assertEquals(true, str.isAlphaSpace());

The above string method will return true, if the string contain alphabet and white spaces.

isAlphaNumeric

  1. String str = 'AlphaNumeric123';
  2. System.assertEquals(true, str.isAlphaNumeric());

The above string method will return true, if the string contain alphabet, numbers.

isAlphanumericSpace

  1. String str = 'Alpha Numeric123';
  2. System.assertEquals(true, str.isAlphanumericSpace());

The above string method will return true, if the string contain alphabet, numbers and white spaces.

isNumeric

  1. String str = '432';
  2. System.assertEquals(true, str.isNumeric());

The above string method will return true, if the string contain numbers only.

isNumericSpace

  1. String str = '432 ';
  2. System.assertEquals(true, str.isNumericSpace());

The above string method will return true, if the string contain numbers with spaces.

isWhitespace

  1. String str = ' ';
  2. System.assertEquals(true, str.isWhitespace());

The above string method will return true, if the string contain only white spaces.

Activities: Assign Tasks to a Queue Salesforce Lightning

Salesforce announced to assign Tasks to a Queue beginning from Spring'20 release. How does it work? In Setup, enter Queues in th...