Guest User

Untitled

a guest
Jul 16th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. public with sharing class GDPR_Dynamic_Extension {
  2.  
  3. public Case thisCase {get; set;}
  4. public List <TaskAndComment> tacList {get; set;}
  5. public List <Integer> indexList = new List<Integer>();
  6.  
  7. //Get the fields from FieldSet
  8. Schema.SObjectType SObjectTypeObj = Schema.getGlobalDescribe().get('Case');
  9. transient Schema.DescribeSObjectResult DescribeSObjectResultObj = SObjectTypeObj.getDescribe();
  10. transient Schema.FieldSet fieldSetObj = DescribeSObjectResultObj.FieldSets.getMap().get('GDPR_Task_Fields');
  11.  
  12. public Integer fieldSetSize = fieldSetObj.getFields().size();
  13.  
  14. public List<Integer> getIntegers() {
  15. indexList = createIndex(fieldSetSize);
  16. return indexList;
  17. }
  18.  
  19. public GDPR_Dynamic_Extension(ApexPages.StandardController controller) {
  20. controller.addFields(new String[]{
  21. 'GDPR_IS_Apps__c',
  22. 'GDPR_TON_Head__c'
  23. });
  24. thisCase = (Case)controller.getRecord();
  25. tacList = new List<taskAndComment>();
  26. }
  27.  
  28. public List<taskAndComment> getTheList() {
  29.  
  30. if (tacList.isEmpty()) {
  31. for (Schema.FieldSetMember eachFieldSetMember : fieldSetObj.getFields()) {
  32.  
  33. String path = eachFieldSetMember.getFieldPath();
  34. String label = eachFieldSetMember.getLabel();
  35. Boolean value = (Boolean)thisCase.get(eachFieldSetMember.getFieldPath());
  36.  
  37. taskAndComment t = new taskAndComment(path, label, value);
  38. tacList.add(t);
  39. }
  40. return tacList;
  41. } else return tacList;
  42. }
  43.  
  44. public PageReference processSelected() {
  45.  
  46. for (Integer i = 0; i < tacList.size() ; i++) {
  47. thisCase.put(tacList[i].fieldPath, tacList[i].fieldValue);
  48. System.debug(tacList[i].taskComment);
  49. }
  50. update thisCase;
  51. return null;
  52. }
  53.  
  54. public class TaskAndComment{
  55.  
  56. public String fieldPath {get; set;}
  57. public String fieldLabel {get; set;}
  58. public Boolean fieldValue {get; set;}
  59. public String taskComment {get; set;}
  60.  
  61. public TaskAndComment(String theFieldPath, String theFieldLabel, Boolean theFieldValue){
  62. System.debug('5');
  63. fieldPath = theFieldPath;
  64. fieldLabel = theFieldLabel;
  65. fieldValue = theFieldValue;
  66. taskComment = '';
  67. }
  68. }
  69.  
  70. public static List<Integer> createIndex(Integer count){
  71. List<Integer> indexList = new List<Integer>();
  72. for (Integer i = 0; i < count; i++) {
  73. indexList.add(i);
  74. }
  75. return indexList;
  76. }
  77.  
  78. public void postToChatter(Id c, String message){
  79. ConnectApi.FeedElement feedElement = ConnectApi.ChatterFeeds.postFeedElement(Network.getNetworkId(), c, ConnectApi.FeedElementType.FeedItem, message);
  80. }
  81. }
Add Comment
Please, Sign In to add comment