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'];
}
}
}
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:
How Do You Lose Currency Trading In Meta Fx Global
Thank you for sharing wonderful information with us to get some idea about that content.
Learn Salesforce CPQ
Salesforce CPQ Online Training
Post a Comment