Menu Bar

Wednesday 17 September 2014

Read Static data from Document Salesforce

Suppose we would like to read static data we would prefer Custom Settings.
What if we have a data more than 255 characters. We can read it from Document as below.

/**
* @description Document helper.
*/
public class DocumentHelper {

 private static List<Document> documentList;


 /**
 * @name getQueryDocument
 * @description Get Query from Document by Name.
 * @param docName Document Name
 * @return String
 */
 public static String getQueryFromDocument(String docName) {
  getQueryDocumentList();

  for (Document document : documentList) {
   if (document.Name == docName) {
    return document.Body.toString();
   }
  }
  return '';
 }


 /**
 * @name getQueryDocumentList
 * @description Get Documents form Queries Folder.
 * @return void
 */
 private static void getQueryDocumentList() {
  if (documentList == null) {
   documentList = [
     SELECT Name, Body
     FROM Document
     WHERE Folder.Name = 'Queries'];
  }
 }
}

3 comments:

21st Century Software Solutions said...
This comment has been removed by a blog administrator.
Steven Cohen said...

How Do You Lose Currency Trading In Meta Fx Global

Lavanya said...

Thank you for sharing wonderful information with us to get some idea about that content.
Learn Salesforce CPQ
Salesforce CPQ Online Training