Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public with sharing class GDPR_Dynamic_Extension {
- public Case thisCase {get; set;}
- public List <TaskAndComment> tacList {get; set;}
- public List <Integer> indexList = new List<Integer>();
- //Get the fields from FieldSet
- Schema.SObjectType SObjectTypeObj = Schema.getGlobalDescribe().get('Case');
- transient Schema.DescribeSObjectResult DescribeSObjectResultObj = SObjectTypeObj.getDescribe();
- transient Schema.FieldSet fieldSetObj = DescribeSObjectResultObj.FieldSets.getMap().get('GDPR_Task_Fields');
- public Integer fieldSetSize = fieldSetObj.getFields().size();
- public List<Integer> getIntegers() {
- indexList = createIndex(fieldSetSize);
- return indexList;
- }
- public GDPR_Dynamic_Extension(ApexPages.StandardController controller) {
- controller.addFields(new String[]{
- 'GDPR_IS_Apps__c',
- 'GDPR_TON_Head__c'
- });
- thisCase = (Case)controller.getRecord();
- tacList = new List<taskAndComment>();
- }
- public List<taskAndComment> getTheList() {
- if (tacList.isEmpty()) {
- for (Schema.FieldSetMember eachFieldSetMember : fieldSetObj.getFields()) {
- String path = eachFieldSetMember.getFieldPath();
- String label = eachFieldSetMember.getLabel();
- Boolean value = (Boolean)thisCase.get(eachFieldSetMember.getFieldPath());
- taskAndComment t = new taskAndComment(path, label, value);
- tacList.add(t);
- }
- return tacList;
- } else return tacList;
- }
- public PageReference processSelected() {
- for (Integer i = 0; i < tacList.size() ; i++) {
- thisCase.put(tacList[i].fieldPath, tacList[i].fieldValue);
- System.debug(tacList[i].taskComment);
- }
- update thisCase;
- return null;
- }
- public class TaskAndComment{
- public String fieldPath {get; set;}
- public String fieldLabel {get; set;}
- public Boolean fieldValue {get; set;}
- public String taskComment {get; set;}
- public TaskAndComment(String theFieldPath, String theFieldLabel, Boolean theFieldValue){
- System.debug('5');
- fieldPath = theFieldPath;
- fieldLabel = theFieldLabel;
- fieldValue = theFieldValue;
- taskComment = '';
- }
- }
- public static List<Integer> createIndex(Integer count){
- List<Integer> indexList = new List<Integer>();
- for (Integer i = 0; i < count; i++) {
- indexList.add(i);
- }
- return indexList;
- }
- public void postToChatter(Id c, String message){
- ConnectApi.FeedElement feedElement = ConnectApi.ChatterFeeds.postFeedElement(Network.getNetworkId(), c, ConnectApi.FeedElementType.FeedItem, message);
- }
- }
Add Comment
Please, Sign In to add comment