• Jonathan Wolff 7
  • NEWBIE
  • 345 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 211
    Questions
  • 86
    Replies
Hello, I created a custom searchbar component that looks through records of a custom object. I have two rewuirements. first I want to show results by clicking the enter button instead just by clicking the search button. Second requirement is, that i want a drop down with all Typ-categories so i can filter results by these before searching.

My code:

COMPONENT
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="MediathekSearchController">
    
    <!-- handlers-->
    <aura:handler name="init" value="{!this}" action="{!c.init}"/>
    
    <!-- attributes -->
    <aura:attribute name="showSearchResults" type="Boolean" default="false"/>
    <aura:attribute name="searchKey" type="String"/>
    <aura:attribute name="mediathekList" type="List" default="Mediathek[]"/>
    <aura:attribute name="mediathekColumns" type="List"/>
    
    <div class= "slds-box">
        <div class="slds-grid slds-wrap" >
            <div class="slds-size_12-of-12">
        <lightning:layout multipleRows="true">
            <lightning:layoutItem  size="9">
                <lightning:input name="searchKey" placeholder="Suchbegriff einfügen" value="{!v.searchKey}"/>
            </lightning:layoutItem>
            <lightning:layoutItem  size="2">
                <lightning:button variant="brand" label="Suchen" title="Search" onclick="{!c.search}" class="customButton"/>
            </lightning:layoutItem>
        </lightning:layout>
    </div>
    </div>
    <div class="haha">
        <aura:if isTrue="{!v.showSearchResults}">
            <lightning:layout multipleRows="true">
                <lightning:layoutItem padding="around-small" size="12" >
                    <lightning:datatable keyField="id"
                                         data="{!v.mediathekList}"
                                         columns="{!v.mediathekColumns}"
                                         hideCheckboxColumn="true"/>
                </lightning:layoutItem>
            </lightning:layout>
        </aura:if>
    </div>
        </div>
    
    
    
</aura:component>

JS:
({
    init: function (component, event, helper){
       component.set('v.mediathekColumns', [
            {label: 'Bezeichnung', fieldName: 'Bezeichnung_Search__c', type: 'url' , fixedWidth: 395, 
             typeAttributes: {label: { fieldName: 'Bezeichnung__c' }, target: '_blank'}
            },
           {label: 'Typ', fieldName: 'Typ__c', type: 'text',  fixedWidth: 116,
            },
           {label: 'Zielgruppe', fieldName: 'Zielgruppe__c', type: 'text', fixedWidth: 116,
            },
           {label: 'Umfang', fieldName: 'Umfang__c', type: 'text', fixedWidth: 112,
           },
           
         
          ]);
             var action = component.get("c.getSearchResult");
       
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                var records =response.getReturnValue();
                records.forEach(function(record){
                    
           			record.BEZ = record.Bezeichnung__c;
                });
                component.set("v.mediathekList", records);
            }
        });
        $A.enqueueAction(action);
    },




        
    search : function(component, event, helper) {
        helper.getSearchResultsFromApex(component, event, helper);
        component.set("v.showSearchResults",true);
    }
})

HELPER
({
    getSearchResultsFromApex : function(component, event, helper){
     
        var action = component.get("c.getSearchResult");
        action.setParams({ searchKey : component.get("v.searchKey") });
     
        // Create a callback that is executed after
        // the server-side action returns
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
 var result = response.getReturnValue();
  result.forEach(function(result){
                    result.Name = '/'+result.Id;
      				
                });
               
                // SOSL will always return the list in the order they were queried
                component.set("v.mediathekList",result[0]);
                  
                
            }
            else if (state === "INCOMPLETE") {
                // do something
            }
                else if (state === "ERROR") {
                    var errors = response.getError();
                    if (errors) {
                        if (errors[0] && errors[0].message) {
                            console.log("Error message: " +
                                        errors[0].message);
                        }
                    } else {
                        console.log("Unknown error");
                    }
                }
        });
        $A.enqueueAction(action);
    }
})
APEX Controller
 
public class MediathekSearchController {


    
    @AuraEnabled(cacheable=true)
    public static List<List<sObject>> getSearchResult(String searchKey){
     String findStr = '*'+searchKey+'*';
        system.debug('searchKey ' + searchKey);
        system.debug('findStr ' + findStr);
        List<List<sObject>> searchResult = [FIND : findStr
                                            IN ALL FIELDS RETURNING
                                            Mediathek__c (Id, Name, Bezeichnung__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c)
                                            ];
        return searchResult;
     
    } 
}

​​​​​​​​​​​​​​
Hello, I have following requirement: I want to enter an ID into a flow and then check if the Id is part of the account ids in my org. Is there a way to do this with decision element.
Hope the topic is understandable.

Greetings Jonathan
Hello, I have a datatable with dates in one column. Can you please help me changing my current code so the sortation functions?
I have no idea how the code is modified in the right way.

My code:
 
<aura:component controller="ApexActivityWrapper" implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" access="global">  
    
    <aura:attribute name="taskEventList2" type="object"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInIt}"/>
    <aura:attribute name="mycolumns" type="List"/>

    
    <div style= "font-size: 14px; font-weight: bold; margin-left:15px; margin-top:10px;">
        ActivityList        
    </div>
    <div>
        <aura:if isTrue="{!not(empty(v.taskEventList2))}">
            <lightning:datatable data="{!v.taskEventList2}" 
                                 columns="{!v.mycolumns}" 
                                 keyField="Id"
                                 hideCheckboxColumn="true"/>
            <aura:set attribute="else">
                <div Style="text-align : center">Keine Aufgaben</div>
            </aura:set>
        </aura:if>
    </div>
</aura:component>
 
({
    doInIt : function(component, event, helper) {
        component.set('v.mycolumns', [
            {label: "Datum", 			fieldName: "DatumOut", sortable:true,		type: "date-local", typeAttributes:	{month: "2-digit", day: "2-digit" }},           
            {label: 'Typ', 				fieldName: 'TypOut', 	type: 'text'},
            {label: 'Thema', 			fieldName: 'ThemaOut', 	type: 'string', 		typeAttributes: {label: { fieldName: 'sub' }, target: '_blank'}},
            {label: 'Bezug zu', 		fieldName: 'BezugOut', 	type: 'text'},          
            {label: 'Zugewiesen zu', 	fieldName: 'ZugewiesenOut',	type: 'text'},          
        ]);
            var action = component.get("c.ApexActivityWrapper");
			var recordId = component.get('v.recordId');
            action.setParams({ recordId : recordId });
            
            action.setCallback(this, function(response){
            var state = response.getState();
            console.log('state==='+state);
            if(state === "SUCCESS")
            {
            var response = response.getReturnValue();
            console.log('response==='+JSON.stringify(response));          
            component.set("v.taskEventList2", response);
            } else if(state === "INCOMPLETE") {
            	//do something 
            } else if(state === "ERROR") {
            	var error = response.getError();
            	if(error) {
            		console.log("error"+error);
            	}
            }
            });
            $A.enqueueAction(action);
            },
            
            
            
            
            updateSorting: function (cmp, event, helper) {
        var fieldName = event.getParam('fieldName');
        var sortDirection = event.getParam('sortDirection');
        cmp.set("v.sortedBy", fieldName);
        cmp.set("v.sortedDirection", sortDirection);
        helper.sortData(cmp, fieldName, sortDirection);
    },
})
 
({
	 sortData: function (cmp, fieldName, sortDirection) {
        var fname = fieldName;
        var data = cmp.get("v.recordList");
        var reverse = sortDirection !== 'asc';
        data.sort(this.sortBy(fieldName, reverse))
        cmp.set("v.recordList", data);
    },
    sortBy: function (field, reverse) {
        var key = function(x) {return x[field]};
        reverse = !reverse ? 1 : -1;
        return function (a, b) {
            return a = key(a), b = key(b), reverse * ((a > b) - (b > a));
        }
    }
})
 
public Class ApexActivityWrapper {    
    @auraEnabled
    public static List<eEventTTask> ApexActivityWrapper (String recordId) {     
        system.debug('recordId =' + recordId);
        List<eEventTTask> taskEventList = new List<eEventTTask>();  
        // Abfrage von Terminen/Events
        for (Event e: [SELECT Id, Subject, ActivityDate, What.Name, Owner.Name FROM Event WHERE Id IN (select EventId from EventRelation where RelationId = :recordId)]) {
            taskEventList.add(new eEventTTask(e.Subject, e.ActivityDate, 'E', e.What.Name, e.Owner.Name));
        }
        // Abfrage von Aufgaben/Tasks
        for (Task t: [SELECT Id, Subject, ActivityDate, What.Name, Owner.Name FROM Task WHERE Id IN (select TaskId from TaskRelation where RelationId = :recordId)]) {
            taskEventList.add(new eEventTTask(t.Subject, t.ActivityDate, 'T', t.What.Name, t.Owner.Name));
        }
        // Abfrage von Email-Messages
       // for (EmailMessage emm: [SELECT Id, Subject, MessageDate, LastModifiedDate FROM EmailMessage WHERE Id IN (select EmailMessageId from EmailMessageRelation where RelationId = :recordId)]) {
        //   taskEventList.add(new eEventTTask(emm.Subject, emm.LastModifiedDate, 'EMM',  emm.Subject, emm.Subject));
      //  }
        // Abfrage von Notizen/Notes
        for(Note n: [SELECT Id, Title, CreatedDate, Createdby.Name, Owner.Name, Parent.Name, ParentId FROM Note WHERE ParentId = :recordId]) {
            taskEventList.add(new eEventTTask(n.Title, date.newInstance(n.CreatedDate.year(), n.CreatedDate.month(), n.CreatedDate.day()), 'N', n.Parent.Name, n.Owner.Name));
        }  
        // Abrage von Anlagen/Dateien (alte Version - wird von Salesforce irgendwann abgestellt)
        for(Attachment a: [SELECT Id, Name, CreatedDate, Createdby.Name, Owner.Name, Parent.Name, ParentId FROM Attachment WHERE ParentId = :recordId]) {
            taskEventList.add(new eEventTTask(a.Name, date.newInstance(a.CreatedDate.year(), a.CreatedDate.month(), a.CreatedDate.day()), 'A', a.Parent.Name, a.Owner.Name));
        }
        // Abfrage von Notizen (neue Version)
        for(ContentDocumentLink c: [SELECT Id, ContentDocumentId, ContentDocument.Title, ContentDocument.createdDate, ContentDocument.Createdby.Name, ContentDocument.FileExtension, LinkedEntity.Id, LinkedEntity.Name FROM ContentDocumentLink WHERE LinkedEntityId = :recordId]) {
            taskEventList.add(new eEventTTask(c.ContentDocument.Title, date.newInstance(c.ContentDocument.CreatedDate.year(), c.ContentDocument.CreatedDate.month(), c.ContentDocument.CreatedDate.day()), 'C', c.LinkedEntity.Name, c.ContentDocument.CreatedBy.Name));
        }
        system.debug('taskEventList' + taskEventList);
        return taskEventList;
    }
    
    public class eEventTTask {
        @AuraEnabled
        public String ThemaOut {get; set;}
        @AuraEnabled
        public Date DatumOut {get; set;}
        @AuraEnabled
        public String TypOut {get; set;}
        @AuraEnabled
        public String BezugOut {get; set;}
        @AuraEnabled
        public String ZugewiesenOut {get; set;}
        
        public eEventTTask(String ThemaIn, Date DatumIn, String TypIn, String BezugIn, String ZugewiesenIn) {         
            ThemaOut 		= ThemaIn;
            DatumOut	 	= DatumIn;
            TypOut			= TypIn;
            BezugOut		= BezugIn;
            ZugewiesenOut	= ZugewiesenIn;
        }
    }
}

 
Hello, I want to sort my datatable-component by date. I already tried to implement sort-function in controller like in: in: https://www.salesforcebolt.com/2020/04/add-sorting-in-lightning-data-table.html (https://www.salesforcebolt.com/2020/04/add-sorting-in-lightning-data-table.html" style="color:#0563c1; text-decoration:underline)


Could you tell mehow to change my code to make the sorting of the rows descending by date?
 
<aura:component controller="ApexActivityWrapper" implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" access="global">  
    
    <aura:attribute name="taskEventList2" type="object"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInIt}"/>
    <aura:attribute name="mycolumns" type="List"/>

    
    <div style= "font-size: 14px; font-weight: bold; margin-left:15px; margin-top:10px;">
        ActivityList        
    </div>
    <div>
        <aura:if isTrue="{!not(empty(v.taskEventList2))}">
            <lightning:datatable data="{!v.taskEventList2}" 
                                 columns="{!v.mycolumns}" 
                                 keyField="Id"
                                 hideCheckboxColumn="true"/>
            <aura:set attribute="else">
                <div Style="text-align : center">Keine Aufgaben</div>
            </aura:set>
        </aura:if>
    </div>
</aura:component>
 
({
    doInIt : function(component, event, helper) {
        component.set('v.mycolumns', [
            {label: "Datum", 			fieldName: "DatumOut", sortable:true,		type: "date-local", typeAttributes:	{month: "2-digit", day: "2-digit" }},           
            {label: 'Typ', 				fieldName: 'TypOut', 	type: 'text'},
            {label: 'Thema', 			fieldName: 'ThemaOut', 	type: 'string', 		typeAttributes: {label: { fieldName: 'sub' }, target: '_blank'}},
            {label: 'Bezug zu', 		fieldName: 'BezugOut', 	type: 'text'},          
            {label: 'Zugewiesen zu', 	fieldName: 'ZugewiesenOut',	type: 'text'},          
        ]);
            var action = component.get("c.ApexActivityWrapper");
			var recordId = component.get('v.recordId');
            action.setParams({ recordId : recordId });
            
            action.setCallback(this, function(response){
            var state = response.getState();
            console.log('state==='+state);
            if(state === "SUCCESS")
            {
            var response = response.getReturnValue();
            console.log('response==='+JSON.stringify(response));          
            component.set("v.taskEventList2", response);
            } else if(state === "INCOMPLETE") {
            	//do something 
            } else if(state === "ERROR") {
            	var error = response.getError();
            	if(error) {
            		console.log("error"+error);
            	}
            }
            });
            $A.enqueueAction(action);
            },
            
            
            
            
            updateSorting: function (cmp, event, helper) {
        var fieldName = event.getParam('fieldName');
        var sortDirection = event.getParam('sortDirection');
        cmp.set("v.sortedBy", fieldName);
        cmp.set("v.sortedDirection", sortDirection);
        helper.sortData(cmp, fieldName, sortDirection);
    },
})
 
({
	 sortData: function (cmp, fieldName, sortDirection) {
        var fname = fieldName;
        var data = cmp.get("v.recordList");
        var reverse = sortDirection !== 'asc';
        data.sort(this.sortBy(fieldName, reverse))
        cmp.set("v.recordList", data);
    },
    sortBy: function (field, reverse) {
        var key = function(x) {return x[field]};
        reverse = !reverse ? 1 : -1;
        return function (a, b) {
            return a = key(a), b = key(b), reverse * ((a > b) - (b > a));
        }
    }
})
 
public Class ApexActivityWrapper {    
    @auraEnabled
    public static List<eEventTTask> ApexActivityWrapper (String recordId) {     
        system.debug('recordId =' + recordId);
        List<eEventTTask> taskEventList = new List<eEventTTask>();  
        // Abfrage von Terminen/Events
        for (Event e: [SELECT Id, Subject, ActivityDate, What.Name, Owner.Name FROM Event WHERE Id IN (select EventId from EventRelation where RelationId = :recordId)]) {
            taskEventList.add(new eEventTTask(e.Subject, e.ActivityDate, 'E', e.What.Name, e.Owner.Name));
        }
        // Abfrage von Aufgaben/Tasks
        for (Task t: [SELECT Id, Subject, ActivityDate, What.Name, Owner.Name FROM Task WHERE Id IN (select TaskId from TaskRelation where RelationId = :recordId)]) {
            taskEventList.add(new eEventTTask(t.Subject, t.ActivityDate, 'T', t.What.Name, t.Owner.Name));
        }
        // Abfrage von Email-Messages
       // for (EmailMessage emm: [SELECT Id, Subject, MessageDate, LastModifiedDate FROM EmailMessage WHERE Id IN (select EmailMessageId from EmailMessageRelation where RelationId = :recordId)]) {
        //   taskEventList.add(new eEventTTask(emm.Subject, emm.LastModifiedDate, 'EMM',  emm.Subject, emm.Subject));
      //  }
        // Abfrage von Notizen/Notes
        for(Note n: [SELECT Id, Title, CreatedDate, Createdby.Name, Owner.Name, Parent.Name, ParentId FROM Note WHERE ParentId = :recordId]) {
            taskEventList.add(new eEventTTask(n.Title, date.newInstance(n.CreatedDate.year(), n.CreatedDate.month(), n.CreatedDate.day()), 'N', n.Parent.Name, n.Owner.Name));
        }  
        // Abrage von Anlagen/Dateien (alte Version - wird von Salesforce irgendwann abgestellt)
        for(Attachment a: [SELECT Id, Name, CreatedDate, Createdby.Name, Owner.Name, Parent.Name, ParentId FROM Attachment WHERE ParentId = :recordId]) {
            taskEventList.add(new eEventTTask(a.Name, date.newInstance(a.CreatedDate.year(), a.CreatedDate.month(), a.CreatedDate.day()), 'A', a.Parent.Name, a.Owner.Name));
        }
        // Abfrage von Notizen (neue Version)
        for(ContentDocumentLink c: [SELECT Id, ContentDocumentId, ContentDocument.Title, ContentDocument.createdDate, ContentDocument.Createdby.Name, ContentDocument.FileExtension, LinkedEntity.Id, LinkedEntity.Name FROM ContentDocumentLink WHERE LinkedEntityId = :recordId]) {
            taskEventList.add(new eEventTTask(c.ContentDocument.Title, date.newInstance(c.ContentDocument.CreatedDate.year(), c.ContentDocument.CreatedDate.month(), c.ContentDocument.CreatedDate.day()), 'C', c.LinkedEntity.Name, c.ContentDocument.CreatedBy.Name));
        }
        system.debug('taskEventList' + taskEventList);
        return taskEventList;
    }
    
    public class eEventTTask {
        @AuraEnabled
        public String ThemaOut {get; set;}
        @AuraEnabled
        public Date DatumOut {get; set;}
        @AuraEnabled
        public String TypOut {get; set;}
        @AuraEnabled
        public String BezugOut {get; set;}
        @AuraEnabled
        public String ZugewiesenOut {get; set;}
        
        public eEventTTask(String ThemaIn, Date DatumIn, String TypIn, String BezugIn, String ZugewiesenIn) {         
            ThemaOut 		= ThemaIn;
            DatumOut	 	= DatumIn;
            TypOut			= TypIn;
            BezugOut		= BezugIn;
            ZugewiesenOut	= ZugewiesenIn;
        }
    }
}



 
Hello, I got a set of columns for my datatable, but the problem is they appear without the columns being ordered by date:
User-added image

I cant order it through my Sql query because i got a wrapper class. Can you show me how to use sorting in datatable with controller.

Component:
<aura:component controller="ApexActivityWrapper" implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" access="global">  
    
    <aura:attribute name="taskEventList2" type="object"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInIt}"/>
    <aura:attribute name="mycolumns" type="List"/>

    
    <div style= "font-size: 14px; font-weight: bold; margin-left:15px; margin-top:10px;">
        ActivityList        
    </div>
    <div>
        <aura:if isTrue="{!not(empty(v.taskEventList2))}">
            <lightning:datatable data="{!v.taskEventList2}" 
                                 columns="{!v.mycolumns}" 
                                 keyField="Id"
                                 hideCheckboxColumn="true"/>
            <aura:set attribute="else">
                <div Style="text-align : center">Keine Aufgaben</div>
            </aura:set>
        </aura:if>
    </div>
</aura:component>

Controller:
({
    doInIt : function(component, event, helper) {
        component.set('v.mycolumns', [
            {label: "Datum", 			fieldName: "DatumOut", 		type: "date-local", typeAttributes:	{month: "2-digit", day: "2-digit" }},           
            {label: 'Typ', 				fieldName: 'TypOut', 				type: 'text'},
            {label: 'Thema', 			fieldName: 'ThemaOut', 			type: 'string', 		typeAttributes: {label: { fieldName: 'sub' }, target: '_blank'}},
            {label: 'Bezug zu', 		fieldName: 'BezugOut', 			type: 'text'},          
            {label: 'Zugewiesen zu', 	fieldName: 'ZugewiesenOut', 	type: 'text'},          
        ]);
            var action = component.get("c.ApexActivityWrapper");
			var recordId = component.get('v.recordId');
            action.setParams({ recordId : recordId });
            
            action.setCallback(this, function(response){
            var state = response.getState();
            console.log('state==='+state);
            if(state === "SUCCESS")
            {
            var response = response.getReturnValue();
            console.log('response==='+JSON.stringify(response));          
            component.set("v.taskEventList2", response);
            } else if(state === "INCOMPLETE") {
            	//do something 
            } else if(state === "ERROR") {
            	var error = response.getError();
            	if(error) {
            		console.log("error"+error);
            	}
            }
            });
            $A.enqueueAction(action);
            }
})

Apex:
 
public Class ApexActivityWrapper {    
    @auraEnabled
    public static List<eEventTTask> ApexActivityWrapper (String recordId) {     
        system.debug('recordId =' + recordId);
        List<eEventTTask> taskEventList = new List<eEventTTask>();  
        // Abfrage von Terminen/Events
        for (Event e: [SELECT Id, Subject, ActivityDate, What.Name, Owner.Name FROM Event WHERE Id IN (select EventId from EventRelation where RelationId = :recordId)]) {
            taskEventList.add(new eEventTTask(e.Subject, e.ActivityDate, 'E', e.What.Name, e.Owner.Name));
        }
        // Abfrage von Aufgaben/Tasks
        for (Task t: [SELECT Id, Subject, ActivityDate, What.Name, Owner.Name FROM Task WHERE Id IN (select TaskId from TaskRelation where RelationId = :recordId)]) {
            taskEventList.add(new eEventTTask(t.Subject, t.ActivityDate, 'T', t.What.Name, t.Owner.Name));
        }
        // Abfrage von Email-Messages
   //     for (EmailMessage emm: [SELECT Id, Subject, MessageDate FROM EmailMessage WHERE Id IN (select EmailMessageId from EmailMessageRelation where RelationId = :recordId)]) {
   //         taskEventList.add(new eEventTTask(emm.Subject, emm.MessageDate, 'EMM'));
   //     }
        // Abfrage von Notizen/Notes
        for(Note n: [SELECT Id, Title, CreatedDate, Createdby.Name, Owner.Name, Parent.Name, ParentId FROM Note WHERE ParentId = :recordId]) {
            taskEventList.add(new eEventTTask(n.Title, date.newInstance(n.CreatedDate.year(), n.CreatedDate.month(), n.CreatedDate.day()), 'N', n.Parent.Name, n.Owner.Name));
        }  
        // Abrage von Anlagen/Dateien (alte Version - wird von Salesforce irgendwann abgestellt)
        for(Attachment a: [SELECT Id, Name, CreatedDate, Createdby.Name, Owner.Name, Parent.Name, ParentId FROM Attachment WHERE ParentId = :recordId]) {
            taskEventList.add(new eEventTTask(a.Name, date.newInstance(a.CreatedDate.year(), a.CreatedDate.month(), a.CreatedDate.day()), 'A', a.Parent.Name, a.Owner.Name));
        }
        // Abfrage von Notizen (neue Version)
        for(ContentDocumentLink c: [SELECT Id, ContentDocumentId, ContentDocument.Title, ContentDocument.createdDate, ContentDocument.Createdby.Name, ContentDocument.FileExtension, LinkedEntity.Id, LinkedEntity.Name FROM ContentDocumentLink WHERE LinkedEntityId = :recordId]) {
            taskEventList.add(new eEventTTask(c.ContentDocument.Title, date.newInstance(c.ContentDocument.CreatedDate.year(), c.ContentDocument.CreatedDate.month(), c.ContentDocument.CreatedDate.day()), 'C', c.LinkedEntity.Name, c.ContentDocument.CreatedBy.Name));
        }
        system.debug('taskEventList' + taskEventList);
        return taskEventList;
    }
    
    public class eEventTTask {
        @AuraEnabled
        public String ThemaOut {get; set;}
        @AuraEnabled
        public Date DatumOut {get; set;}
        @AuraEnabled
        public String TypOut {get; set;}
        @AuraEnabled
        public String BezugOut {get; set;}
        @AuraEnabled
        public String ZugewiesenOut {get; set;}
        
        public eEventTTask(String ThemaIn, Date DatumIn, String TypIn, String BezugIn, String ZugewiesenIn) {         
            ThemaOut 		= ThemaIn;
            DatumOut	 	= DatumIn;
            TypOut			= TypIn;
            BezugOut		= BezugIn;
            ZugewiesenOut	= ZugewiesenIn;
        }
    }
}

​​​​​​​​​​​​​​
 
 
Hello, I build a apex class myself which results in a value named "Rows". I would like to display the value within a datatable component. But with the code I tried to build, I get the following error. Could you tell me how to change my code so I can display the rows in a datatable component?

User-added image

COMPONENT
<aura:component controller="ApexActivityWrapper" implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" access="global">  
   
    
    <aura:attribute name="RowList" type="List"/>
    
      <aura:handler name="init" value="{!this}" action="{!c.doInIt}"/>
   	
   


    
     <p align="center" class="slds-text-heading_large ">Task List</p>
    <table class="slds-table slds-table_cell-buffer slds-table_bordered slds-table_striped">
     <thead>
       <tr class="slds-line-height_reset">
        <th class="" scope="col">
       <div class="slds-truncate" >
        Row Subject
        </div>
         </th> 
         </tr>
        </thead>
        <tbody>
         <tr class="slds-hint-parent">
         <th data-label="" scope="row">
          <div class="slds-truncate" >
          
           <aura:iteration items="{!v.rows}" var="row">
            <p>{!row.Subject}</p><br/>
            </aura:iteration>
             </div>
              </th>
              </tr>
        </tbody>
    </table>
   
    <br/>
    <br/>
</aura:component>

CONTROLLER:
 
({
     doInIt : function(component, event, helper) {

       
        action.setCallback(this, function(response){
            var state = response.getState();
            if(state === "SUCCESS")
            {
     var response = response.getReturnValue();
     component.set("v.wrapperList", response); 
     component.set("v.activityWrapper", response); 
     component.set("v.RowList", response.rows); 
     
       
            }
            else if(state === "INCOMPLETE")
            {
                //do something 
            }
            else if(state === "ERROR")
            {
             var error = response.getError();
             if(error)
             {
                 console.log("error"+error);
             }
            }
        });
          $A.enqueueAction(action);
 }
})

Apex Controller
 
public Class ApexActivityWrapper {
   
    private Contact c;
    public List<Row> rows {get; set;}
    public Class Row implements Comparable {
        public String Subject {get; set;}
        public Datetime ActivityDate {get; set;}
        Row(String Subject, Datetime ActivityDate) {
            this.Subject = subject;
            this.ActivityDate = ActivityDate;
        }
        public Integer compareTo(Object o) {
            Row that = (Row) o;
            if (that.ActivityDate < this.ActivityDate) return 1;
            else if (that.ActivityDate > this.ActivityDate) return -1;
            else return 0;
        }
    }
    public ApexActivityWrapper () {
        rows = new List<Row>();
        for (Event evt : [
                SELECT Subject, ActivityDate FROM Event ORDER BY ActivityDate LIMIT 10
                ]) {
            rows.add(new Row(evt.Subject, evt.ActivityDate));
        }
        for (Task tsk: [
                SELECT Subject, ActivityDate FROM Task ORDER BY ActivityDate LIMIT 10
                ]) {
            rows.add(new Row(tsk.Subject, tsk.ActivityDate));
        }
        rows.sort();
        system.debug('ROWS' + rows);
    }
  
}

​​​​​​​​​​​​​​

 
Hello,
I want to display the List "rows" from my Apex Class in my component. I have no idea how to manage it. Could you help me fixing my component and controller I have. I tried a lot, but i get errors every time:

Component:
 
<aura:component controller="ApexActivityWrapper" implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" access="global">  
   
    <aura:attribute name="recordId" type="Id" />    
    <aura:attribute name="rows" type="Row[]"/>
    <aura:attribute name="RowList" type="List"/>
      <aura:handler name="init" value="{!this}" action="{!c.doInIt}"/>
   	
  
     <p align="center" class="slds-text-heading_large ">Task List</p>
    <table class="slds-table slds-table_cell-buffer slds-table_bordered slds-table_striped">
     <thead>
       <tr class="slds-line-height_reset">
        <th class="" scope="col">
       <div class="slds-truncate" >
        Row Subject
        </div>
         </th> 
         </tr>
        </thead>
        <tbody>
         <tr class="slds-hint-parent">
         <th data-label="" scope="row">
          <div class="slds-truncate" >
          
           <aura:iteration items="{!v.rows}" var="row">
            <p>{!row.Subject}</p><br/>
            </aura:iteration>
             </div>
              </th>
              </tr>
        </tbody>
    </table>
   
    <br/>
    <br/>
</aura:component>

Controller:
 
({
     doInIt : function(component, event, helper) {

        component.set("v.RowList", response.rows);  
    
    
        var action = component.get("c.rows");
            action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                var records =response.getReturnValue();
                records.forEach(function(record){
                   
           
                });
                component.set("v.RowList", response.rows);
            }
        });
        $A.enqueueAction(action);

}

APEX:
 
public Class ApexActivityWrapper {
   
    private Contact c;
    public List<Row> rows {get; set;}
    public Class Row implements Comparable {
        public String Subject {get; set;}
        public Datetime ActivityDate {get; set;}
        Row(String Subject, Datetime ActivityDate) {
            this.Subject = subject;
            this.ActivityDate = ActivityDate;
        }
        public Integer compareTo(Object o) {
            Row that = (Row) o;
            if (that.ActivityDate < this.ActivityDate) return 1;
            else if (that.ActivityDate > this.ActivityDate) return -1;
            else return 0;
        }
    }
    public ApexActivityWrapper () {
        rows = new List<Row>();
        for (Event evt : [
                SELECT Subject, ActivityDate FROM Event ORDER BY ActivityDate LIMIT 10
                ]) {
            rows.add(new Row(evt.Subject, evt.ActivityDate));
        }
        for (Task tsk: [
                SELECT Subject, ActivityDate FROM Task ORDER BY ActivityDate LIMIT 10
                ]) {
            rows.add(new Row(tsk.Subject, tsk.ActivityDate));
        }
        rows.sort();
        system.debug('ROWS' + rows);
    }
  
}

​​​​​​​​​​​​​​
Hello, so I try to create a datatable component that displays tasks and events of a contact in a single table. 
task1   ActivityDate
task2   ActivityDate
event1   ActivityDate
task3   ActivityDate
event2   ActivityDate
event3   ActivityDate

For now I created a code that shows both tasks and events but in two seperated areas, but I really do not know what approach I should take to combine the results of these two. Maybe you could help me with this topic. So my Controller now is like that:
 
public class ApexActivityWrapper {

 @AuraEnabled
	public static wrapper method1 (){
        
        string userId = UserInfo.getUserId();
        
    List<Task> getTask = [SELECT Subject, ActivityDate FROM Task WHERE OwnerId=:userId ORDER BY ActivityDate];
    List<Event> getEvent =	[SELECT Subject, ActivityDate FROM Event WHERE OwnerId=:userId ORDER BY ActivityDate];
                             
           wrapper wrp = new wrapper();
    	wrp.taskList = new List<Task>(getTask);
    	wrp.eventList = new List<Event>(getEvent);
    return wrp;
}

	public class wrapper{
    
   	 	@AuraEnabled
    		public List<Task> taskList ;
    	@AuraEnabled
    		public List <Event> eventList;
	}
}

 
Hello, I have a component that includes rows from different objects in one List. But I cant see if it works because I get the following error. Could you try the code out in your org and look if it works?

User-added image

My code ist as follows
Component:
<aura:component controller="ApexActivityWrapper" implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" access="global">  
   
    
    <aura:attribute name="TaskList" type="List"/>
    <aura:attribute name="EventList" type="List"/>
    <aura:attribute name="activityWrapper" type="object"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInIt}"/>
   	<aura:attribute name="wrapperList" type="ApexActivityWrapper.wrapper[]"/>
    
	<aura:iteration items="{!v.wrapperList}" var="wrp">
   {!wrp.taskSubject} - {!wrp.taskSubject}
   {!wrp.eventSubject} - {!wrp.eventActivityDate}
</aura:iteration>


    
     <p align="center" class="slds-text-heading_large ">Task List</p>
    <table class="slds-table slds-table_cell-buffer slds-table_bordered slds-table_striped">
     <thead>
       <tr class="slds-line-height_reset">
        <th class="" scope="col">
       <div class="slds-truncate" >
        Task Subject
        </div>
         </th> 
         </tr>
        </thead>
        <tbody>
         <tr class="slds-hint-parent">
         <th data-label="" scope="row">
          <div class="slds-truncate" >
          
           <aura:iteration items="{!v.TaskList}" var="task">
            <p>{!task.Subject}</p><br/>
            </aura:iteration>
             </div>
              </th>
              </tr>
        </tbody>
    </table>
    
    <p align="center" class="slds-text-heading_large ">Event List</p>
    <table class="slds-table slds-table_cell-buffer slds-table_bordered slds-table_striped">
     <thead>
       <tr class="slds-line-height_reset">
        <th class="" scope="col">
       <div class="slds-truncate" >
        Event Subject
        </div>
         </th> 
         </tr>
        </thead>
        <tbody>
         <tr class="slds-hint-parent">
         <th data-label="" scope="row">
          <div class="slds-truncate" >
           
           <aura:iteration items="{!v.EventList}" var="event">
            <p>{!event.Subject}</p><br/>
            </aura:iteration>
             </div>
              </th>
              </tr>
        </tbody>
    </table>
    <aura:iteration items="{!v.activitytWrapper.wrp }" var="act">
                <tr>
                    <th scope="row">
                        <div class="slds-truncate" title="{!act.subject}">{!act.subject}</div>
                    </th>
                   
                </tr>
            </aura:iteration>

    <br/>
    <br/>
</aura:component>

Controller
({
     doInIt : function(component, event, helper) {
 var action = component.get("c.method1");

       
        action.setCallback(this, function(response){
            var state = response.getState();
            if(state === "SUCCESS")
            {
     var response = response.getReturnValue();
     component.set("v.wrapperList", response); 
     component.set("v.activityWrapper", response); 
     component.set("v.TaskList", response.taskList); 
     component.set("v.EventList", response.eventList); 
       
            }
            else if(state === "INCOMPLETE")
            {
                //do something 
            }
            else if(state === "ERROR")
            {
             var error = response.getError();
             if(error)
             {
                 console.log("error"+errors);
             }
            }
        });
          $A.enqueueAction(action);
 }
})

Apex Controller
 
public class ApexActivityWrapper {
   @AuraEnabled
   public static List<wrapper> method1() 
   {
        string userId = UserInfo.getUserId();
        List<wrapper> listwrap = new List<wrapper>();
        List<Task> getTaskList = new List<Task>([SELECT Subject, ActivityDate FROM Task WHERE OwnerId = :userId ORDER BY ActivityDate]);
        List<Event> getEventList = new List<Event>([SELECT Subject, ActivityDate FROM Event WHERE OwnerId = :userId ORDER BY ActivityDate]);

        Integer loopCount = getEventList.size() > 0 ? getEventList.size() : getTaskList.size();
        if(loopCount != null && loopCount > 0) 
        {
           for(Integer i = 0; i < loopCount; i++) {
             wrapper wrp = new wrapper();
             if(getTaskList != null && getTaskList.size() >= i && string.isNotEmpty(getTaskList[i].Subject)) {
               wrp.taskSubject = getTaskList[i].Subject;
             }
             if(getTaskList != null && getTaskList.size() >= i && getTaskList[i].ActivityDate != null) {
               wrp.taskActivityDate = getTaskList[i].ActivityDate;
             }
	     if(getEventList != null && getEventList.size() >= i && string.isNotEmpty(getEventList[i].Subject)) {
               wrp.eventSubject = getEventList[i].Subject;
             }
             if(getEventList != null && getEventList.size() >= i && getEventList[i].ActivityDate != null) {
               wrp.eventActivityDate = getEventList[i].ActivityDate;
             }
             listwrap.add(wrp);
           }
        }
        return listwrap;
   }

	public class wrapper{
   	 	@AuraEnabled
    		public string taskSubject;
    	        @AuraEnabled
    		public date taskActivityDate;
    	        @AuraEnabled
    		public string eventSubject;
    	        @AuraEnabled
    		public date eventActivityDate;
	}
}

​​​​​​​​​​​​​​
Hi I build a wrapper class so i can combine results from events and tasks into one list. the problem i have is, that i think i need to split the list in smaller details. Could you show me how to change my apex class so i can use the fields together within one list.

My current class is like that:
 
public class ApexActivityWrapper {

    
 @AuraEnabled
	public static wrapper method1 (){
        
        string userId = UserInfo.getUserId();
        
    List<Task> getTask = [SELECT Subject, ActivityDate FROM Task WHERE OwnerId=:userId ORDER BY ActivityDate Limit 20];
    List<Event> getEvent =	[SELECT Subject, ActivityDate FROM Event WHERE OwnerId=:userId ORDER BY ActivityDate Limit 20];
                             
           wrapper wrp = new wrapper();
    	wrp.taskList = new List<Task>(getTask);
    	wrp.eventList = new List<Event>(getEvent);
    return wrp;
        

}

	public class wrapper{
    
   	 	@AuraEnabled
    		public List<Task> taskList ;
    	@AuraEnabled
    		public List <Event> eventList;
        
        	 
	}
}

But i think the working apex class should have this form but i dont know how i can achive it:
 
public List<Wrapper> wrapperList {get; set;}
    public String currentRecordId {get; set;}
    
    public DokuBox() {
        currentRecordId = ApexPages.currentPage().getParameters().get('id');
        
        if(wrapperList == null) {
            wrapperList = new List<Wrapper>();
            
            for(Task a: [select Id, Subject, CreatedDate, Createdby.Name, Owner.Name, RecordType.Name, Status from Task where WhoId =: currentRecordId AND Subject LIKE 'E-Mail:%']) {
                wrapperList.add(new Wrapper(a, 'E-Mail'));
            }
            for(Task a: [select Id, Subject, CreatedDate, Createdby.Name, Owner.Name, RecordType.Name, Status from Task where WhoId =: currentRecordId AND (NOT Subject LIKE 'E-Mail:%')]) {
                wrapperList.add(new Wrapper(a, 'Aufgabe'));
            }            
            for(Event b: [select Id, Subject, CreatedDate, StartDateTime, Createdby.Name, Owner.Name from Event where WhoId =: currentRecordId]) {
                wrapperList.add(new Wrapper(b, 'Termin'));
            }          
            for(ContentDocumentLink d: [SELECT Id, ContentDocumentId, ContentDocument.Title, ContentDocument.createdDate, ContentDocument.Createdby.Name, ContentDocument.FileExtension FROM ContentDocumentLink WHERE LinkedEntityId =: currentRecordId AND ContentDocument.FileExtension = 'snote']) {
                wrapperList.add(new Wrapper(d, 'Notiz'));
            }
            for(ContentDocumentLink d: [SELECT Id, ContentDocumentId, ContentDocument.Title, ContentDocument.createdDate, ContentDocument.Createdby.Name, ContentDocument.FileExtension FROM ContentDocumentLink WHERE LinkedEntityId =: currentRecordId AND ContentDocument.FileExtension <> 'snote']) {
                wrapperList.add(new Wrapper(d, 'Datei'));
            }            
            wrapperList.sort();
        }
    }
    
    public class Wrapper implements Comparable {
        
        private final String objectLabel;
        private final Id id;
        private final String subject;
        private final DateTime createDate;
        private final String Ersteller;
        private final String Typ;
        private final String Status;
        
        public wrapper(Task t, String oName) { 
            objectLabel 	= oName;
            id 				= t.Id;
            subject 		= t.Subject;
            createDate 		= t.CreatedDate;
            Ersteller 		= t.Owner.Name;
            Typ				= t.RecordType.Name;
            Status			= t.Status;
        }
        
        public wrapper(Event e, String oName) {
            objectLabel 	= oName;
            id 				= e.Id;
            subject 		= e.Subject;
            createDate 		= e.StartDateTime;
            Ersteller 		= e.Owner.Name;
        }
        
        public wrapper(ContentDocumentLink f, String oName) {
            objectLabel 	= oName;
            id 				= f.ContentDocumentId;
            subject 		= f.ContentDocument.Title;
            createDate 		= f.ContentDocument.CreatedDate;
            Ersteller 		= f.ContentDocument.CreatedBy.Name;
            Typ				= f.ContentDocument.FileExtension;
        }
        
        public Id getId() {
            return id;
        }
        
        public String getSubject() {
            return subject;
        }
        
        public String getTyp() {
            return Typ;
        }    
        
        public DateTime getCreatedDate() {
            return createDate;
        }
        
        public String getObjectLabel() {
            return objectLabel;
        }      

        public String getErsteller() {
            return Ersteller;
        }         

        public String getStatus() {
            return Status;
        }

 
Hello,

I have a component that shows results of task and event query in 2 seperated Lists. I want the combined results to be filtered by create date and be limited to 30 results.
So I see results of tasks/events in one List showing the newest one first. 

My code:

COMPONENT:
<aura:component controller="ApexActivityWrapper" implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" access="global">  
   
    <aura:attribute name="TaskList" type="List"/>
   <aura:attribute name="EventList" type="List"/>
     <aura:handler name="init" value="{!this}" action="{!c.doInIt}"/>
    
     <p align="center" class="slds-text-heading_large ">Task List</p>
    <table class="slds-table slds-table_cell-buffer slds-table_bordered slds-table_striped">
     <thead>
       <tr class="slds-line-height_reset">
        <th class="" scope="col">
       <div class="slds-truncate" >
        Task Subject
        </div>
         </th> 
         </tr>
        </thead>
        <tbody>
         <tr class="slds-hint-parent">
         <th data-label="" scope="row">
          <div class="slds-truncate" >
          
           <aura:iteration items="{!v.TaskList}" var="task">
            <p>{!task.Subject}</p><br/>
            </aura:iteration>
             </div>
              </th>
              </tr>
        </tbody>
    </table>
    
    <p align="center" class="slds-text-heading_large ">Event List</p>
    <table class="slds-table slds-table_cell-buffer slds-table_bordered slds-table_striped">
     <thead>
       <tr class="slds-line-height_reset">
        <th class="" scope="col">
       <div class="slds-truncate" >
        Event Subject
        </div>
         </th> 
         </tr>
        </thead>
        <tbody>
         <tr class="slds-hint-parent">
         <th data-label="" scope="row">
          <div class="slds-truncate" >
           
           <aura:iteration items="{!v.EventList}" var="event">
            <p>{!event.Subject}</p><br/>
            </aura:iteration>
             </div>
              </th>
              </tr>
        </tbody>
    </table>
    <br/>
    <br/>
</aura:component>

CONTROLLER:
({
     doInIt : function(component, event, helper) {
 var action = component.get("c.method1");
       
        action.setCallback(this, function(response){
            var state = response.getState();
            if(state === "SUCCESS")
            {
     var response = response.getReturnValue();
     component.set("v.TaskList", response.taskList); 
     component.set("v.EventList", response.eventList); 
       
            }
            else if(state === "INCOMPLETE")
            {
                //do something 
            }
            else if(state === "ERROR")
            {
             var error = response.getError();
             if(error)
             {
                 console.log("error"+errors);
             }
            }
        });
          $A.enqueueAction(action);
 }
})

APEX CONTROLLER
 
public class ApexActivityWrapper {

 @AuraEnabled
	public static wrapper method1 (){
        
        string userId = UserInfo.getUserId();
        
    List<Task> getTask = [SELECT Subject, ActivityDate FROM Task WHERE OwnerId=:userId ORDER BY ActivityDate];
    List<Event> getEvent =	[SELECT Subject, ActivityDate FROM Event WHERE OwnerId=:userId ORDER BY ActivityDate];
                             
           wrapper wrp = new wrapper();
    	wrp.taskList = new List<Task>(getTask);
    	wrp.eventList = new List<Event>(getEvent);
    return wrp;
}

	public class wrapper{
    
   	 	@AuraEnabled
    		public List<Task> taskList ;
    	@AuraEnabled
    		public List <Event> eventList;
	}
}

​​​​​​​​​​​​​​
Hello I want to achive the following. I want to create a datatable component that lists all tasks and events of a contact with the subject, the activity type, the activity date etc.
Is there a way to create a wrapper class which contains these both objects in one datatable?

Greetings
Jonathan
Hello I have an apex controller where I have two querys. I would like to combine the results of these two into one datatable thats why I would like to combine these querys. Could you tell me how to rewrite my apex class to have a combined query
 
public class ActivityController {
 
    
@AuraEnabled
public static List<Task> loadTasks(Id recordId){
    string userId = UserInfo.getUserId();
    return[SELECT Subject, ActivityDate, StartDateTime, EndDateTime FROM Event];
     return[SELECT Subject,  ActivityDate, Status FROM Task ];

	}
}

 
Hello,

I want to combine to querys from task and event together into one query. Can you tell me how I can achive this the beste way?
The UNION command didnt work in the developer console.

Greetings
Jonathan
Hello,

I want to create a custom related List code where i can enter task object values. Could you share a code sample with me how this is possible?

Greetings
Jonathan
Hello,

I want to develop an apex action, that can open an URL when a certain ID is passed in. I created a formula. An ID should be passed into the action and then the URL should be opened. Could you show me a code that is able to achive this?
My formula example:

IF(CONTAINS({!URL_ID_Cmp.VTRURL}, '64191715'), 'https://www.company.com/linder',
IF(CONTAINS({!URL_ID_Cmp.VTRURL}, '64191717'), 'https://www.company.com/striepe',
NULL))
Hello, I want to build a component which is available for screenflows. The topic I have is the following:
I want to create 3 buttons in the component. When one of these buttons is clicked I want automatically be lead to a decision element that finds out which of the 3 buttons was clicked and dependent on it leads me to different screens.

Greetings
Jonathan
Hello, I have a component that I want to use in a flow. The component contains 3 buttons. with the click of the buttons I want to lead to different screens by decision. Could you tell me how I can change the component so I can use the button outcomes in decision. When I click on the buttons nothing happens. I hope it is understandable:

COMPONENT:
 
<aura:component implements="lightning:availableForFlowScreens" access="global" >
    <!-- Get the script text from the flow -->    
    <aura:attribute name="scriptText" type="String" required="true" />
    <!-- Pass the value of the selected option back to the flow -->
    <aura:attribute name="value" type="String" />
    <aura:attribute name="action" type="String" />
    <!-- Display the script to guide the agent's call -->
   
    <!-- Buttons for the agent to click, according to the customer’s response -->
    <div class="slds-p-top_large slds-p-bottom_large">
       
      
  
        <lightning:button label="Ich möchte das Angebot nutzen" class="slds-size_x-large" aura:id="AngebotAnnehmen" iconName="utility:brush" iconPosition="left"  variant="brand" /><br/><br/>
        <lightning:button label="Kontaktdaten und Terminvereinbarung" class="slds-size_x-large" aura:id="KontaktTermin" iconName="utility:call" iconPosition="left" variant="brand" /><br/><br/>
        <lightning:button label="Ich möchte derzeit keine weitere Vorsorge treffen" class="slds-size_x-large" aura:id="KeineVorsorge" iconName="utility:end_messaging_session" iconPosition="left" variant="brand" />                    
    </div>
    
    
</aura:component>

CONTROLLER
 
({
    handleChange : function(component, event, helper) {
        // When an option is selected, navigate to the next screen
        var response = event.getSource().getLocalId();
        component.set("v.value", response);
        var navigate = component.get("v.navigateFlow");
        console.log('navigate'+navigate)
        if(response=='AngebotAnnehmen'){
            navigate("NEXT");
        }
        if(response=='KontaktTermin'){
            navigate("NEXT");
        }
        if(response=='KeineVorsorge'){
            navigate("NEXT");
        }  
    }
})

DESIGN:
 
<design:component>
    <design:attribute name="scriptText" label="Script Text" 
                      description="What the agent should say to the customer" />
    <design:attribute name="action" label="Navigation Action" 
                      description="" />
        
</design:component>

​​​​​​​​​​​​​​
Hello,
I have 2 required fields in Content Version. I want to send email attachements through salesforce Integration into my org. But for the attachements I get the error:
 
Is there any possibility to predefine values for these fields when an email attachements is entered by salesforce Integration (Azure) so I fit the requirement?

Greetings
Jonathan
Hello,
I have the following problem I face:
I have a two required picklist fields in my org on content version. If somebody wants to upload a file he needs to set a picklist value in the fields "Vertraulichkeitsstufe" and "Dokumentenklasse". The problem i have, that when I want to upload a mail from outlook to salesforce through SF Integration, I get the error, that the values have to be assigned. Is there any possibility I can automatically assign values for content version when uploading it?

Greetings
Jonathan
Hello, 
I would like to get a report as a visualforce. For this I made the code:

<apex:page standardController="account"> <analytics:reportChart reportId="00O0Q000000U9CyUAK"></analytics:reportChart> </apex:page>

When adding the visualforce to a page I get the error:

"The report chart is unavailable because the report's format is not summary or matrix."

What do I have to change to make it work?
Hello, I build a List button that Includes a Visualforce Page. When I chose Accounts in List view and click account I only see the blank Page without the account fields. Please tell me how to change it.

<apex:page standardController="Account" renderAs="pdf" recordSetVar="accounts" >
 

<h1>Welcome to APP!</h1>
 
<p>Thank you, <b><apex:outputText value=" {!Account.Name}"/></b>, for 
   working with APP.</p>
 
<p>Your account details are:</p>
 
<table>
<tr><th>Account Name</th>
    <td><apex:outputText value="{!Account.Name}"/></td>
    </tr>
<tr><th>Account Rep</th>
    <td><apex:outputText value="{!Account.Owner.Name}"/></td>
    </tr>
<tr><th>Customer Since</th>
    <td><apex:outputText value="{0,date,long}">
        <apex:param value="{!Account.CreatedDate}"/>
        </apex:outputText></td>
    </tr>
</table>
    
</apex:page>

User-added image


Result:

User-added image
Hello, I have a component that includes rows from different objects in one List. But I cant see if it works because I get the following error. Could you try the code out in your org and look if it works?

User-added image

My code ist as follows
Component:
<aura:component controller="ApexActivityWrapper" implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" access="global">  
   
    
    <aura:attribute name="TaskList" type="List"/>
    <aura:attribute name="EventList" type="List"/>
    <aura:attribute name="activityWrapper" type="object"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInIt}"/>
   	<aura:attribute name="wrapperList" type="ApexActivityWrapper.wrapper[]"/>
    
	<aura:iteration items="{!v.wrapperList}" var="wrp">
   {!wrp.taskSubject} - {!wrp.taskSubject}
   {!wrp.eventSubject} - {!wrp.eventActivityDate}
</aura:iteration>


    
     <p align="center" class="slds-text-heading_large ">Task List</p>
    <table class="slds-table slds-table_cell-buffer slds-table_bordered slds-table_striped">
     <thead>
       <tr class="slds-line-height_reset">
        <th class="" scope="col">
       <div class="slds-truncate" >
        Task Subject
        </div>
         </th> 
         </tr>
        </thead>
        <tbody>
         <tr class="slds-hint-parent">
         <th data-label="" scope="row">
          <div class="slds-truncate" >
          
           <aura:iteration items="{!v.TaskList}" var="task">
            <p>{!task.Subject}</p><br/>
            </aura:iteration>
             </div>
              </th>
              </tr>
        </tbody>
    </table>
    
    <p align="center" class="slds-text-heading_large ">Event List</p>
    <table class="slds-table slds-table_cell-buffer slds-table_bordered slds-table_striped">
     <thead>
       <tr class="slds-line-height_reset">
        <th class="" scope="col">
       <div class="slds-truncate" >
        Event Subject
        </div>
         </th> 
         </tr>
        </thead>
        <tbody>
         <tr class="slds-hint-parent">
         <th data-label="" scope="row">
          <div class="slds-truncate" >
           
           <aura:iteration items="{!v.EventList}" var="event">
            <p>{!event.Subject}</p><br/>
            </aura:iteration>
             </div>
              </th>
              </tr>
        </tbody>
    </table>
    <aura:iteration items="{!v.activitytWrapper.wrp }" var="act">
                <tr>
                    <th scope="row">
                        <div class="slds-truncate" title="{!act.subject}">{!act.subject}</div>
                    </th>
                   
                </tr>
            </aura:iteration>

    <br/>
    <br/>
</aura:component>

Controller
({
     doInIt : function(component, event, helper) {
 var action = component.get("c.method1");

       
        action.setCallback(this, function(response){
            var state = response.getState();
            if(state === "SUCCESS")
            {
     var response = response.getReturnValue();
     component.set("v.wrapperList", response); 
     component.set("v.activityWrapper", response); 
     component.set("v.TaskList", response.taskList); 
     component.set("v.EventList", response.eventList); 
       
            }
            else if(state === "INCOMPLETE")
            {
                //do something 
            }
            else if(state === "ERROR")
            {
             var error = response.getError();
             if(error)
             {
                 console.log("error"+errors);
             }
            }
        });
          $A.enqueueAction(action);
 }
})

Apex Controller
 
public class ApexActivityWrapper {
   @AuraEnabled
   public static List<wrapper> method1() 
   {
        string userId = UserInfo.getUserId();
        List<wrapper> listwrap = new List<wrapper>();
        List<Task> getTaskList = new List<Task>([SELECT Subject, ActivityDate FROM Task WHERE OwnerId = :userId ORDER BY ActivityDate]);
        List<Event> getEventList = new List<Event>([SELECT Subject, ActivityDate FROM Event WHERE OwnerId = :userId ORDER BY ActivityDate]);

        Integer loopCount = getEventList.size() > 0 ? getEventList.size() : getTaskList.size();
        if(loopCount != null && loopCount > 0) 
        {
           for(Integer i = 0; i < loopCount; i++) {
             wrapper wrp = new wrapper();
             if(getTaskList != null && getTaskList.size() >= i && string.isNotEmpty(getTaskList[i].Subject)) {
               wrp.taskSubject = getTaskList[i].Subject;
             }
             if(getTaskList != null && getTaskList.size() >= i && getTaskList[i].ActivityDate != null) {
               wrp.taskActivityDate = getTaskList[i].ActivityDate;
             }
	     if(getEventList != null && getEventList.size() >= i && string.isNotEmpty(getEventList[i].Subject)) {
               wrp.eventSubject = getEventList[i].Subject;
             }
             if(getEventList != null && getEventList.size() >= i && getEventList[i].ActivityDate != null) {
               wrp.eventActivityDate = getEventList[i].ActivityDate;
             }
             listwrap.add(wrp);
           }
        }
        return listwrap;
   }

	public class wrapper{
   	 	@AuraEnabled
    		public string taskSubject;
    	        @AuraEnabled
    		public date taskActivityDate;
    	        @AuraEnabled
    		public string eventSubject;
    	        @AuraEnabled
    		public date eventActivityDate;
	}
}

​​​​​​​​​​​​​​
Hello I have an apex controller where I have two querys. I would like to combine the results of these two into one datatable thats why I would like to combine these querys. Could you tell me how to rewrite my apex class to have a combined query
 
public class ActivityController {
 
    
@AuraEnabled
public static List<Task> loadTasks(Id recordId){
    string userId = UserInfo.getUserId();
    return[SELECT Subject, ActivityDate, StartDateTime, EndDateTime FROM Event];
     return[SELECT Subject,  ActivityDate, Status FROM Task ];

	}
}

 
Hello, I have a XLSXGenerator apex. I want to start the apex by using a button. For now I can only start it by workbench.
In workbench i make apex execute with the command:
XLSXGenerator.generate(new List<String>{})

The XLSXGenarator code is:
 
public class XLSXGenerator {
    //public static String generate(List<String> textList) {
    public static String generate(List<String> AccList) {
        // Build XLSX File Content
        PageReference xlsxTemplate = page.XLSXTemplate;
    //    xlsxTemplate.getParameters().put('textList', System.JSON.serialize(textList));
        xlsxTemplate.getParameters().put('AccList', System.JSON.serialize(AccList));
        Blob xlsxContent;
        if (Test.isRunningtest()) {
            xlsxContent = Blob.valueOf('Sample');
        } else {
            xlsxContent = xlsxTemplate.getContent();
        }
        // Build XLSX File Frame
        StaticResource xlsxTemplateFrame = [SELECT Body FROM StaticResource WHERE Name = 'XLSXTemplateFrame' LIMIT 1];
        Zippex xlsx = new Zippex(xlsxTemplateFrame.Body);
        // Add the Content to the Frame to complete the File
        xlsx.addFile('xl/worksheets/sheet1.xml', xlsxContent, null);
        // Save XLSX File 
        ContentVersion cv = new ContentVersion();
        String title = 'XLSXExample';
        cv.Title = title;
        cv.PathOnClient = title + ' - ' + DateTime.now() + '.xlsx';
        cv.VersionData = xlsx.getZipArchive();
        insert cv;
        Id contentDocumentid = [SELECT Id FROM ContentDocument WHERE LatestPublishedVersionId = :cv.Id].Id;
        return URL.getOrgDomainUrl().toExternalForm() + '/sfc/servlet.shepherd/document/download/' + contentDocumentid;
    }

}

​​​​​​​
Hello, I have a component on account object. I want to render part of the component dependend on if the checkbox 'Urlaub__c' on the ownerUser is true. The problem I have is, that with the way I did it the section Is not showing up even tough the checkbox is true. Could you tell me what to change so that it works?
 
<aura:if isTrue="{!v.OwnerUser.Urlaub__c}">
            <lightning:layoutItem padding="around-small">                
                <br></br> 
                
                <div class="header-column" width="100%">
                    <div style="font-size: 15px;"><b>{!v.OwnerUser.Vertreter__c.Name}</b></div>
                    <div style="font-size: 10px;">Team {!v.OwnerUser.Team_2020__c}</div>
                    <div>
                        <a href="{!'tel:' + v.OwnerUser.Vertreter__c.MobilePhone}"><lightning:icon iconName="action:call" size="xx-small" alternativeText="Telefon" title="Telefon"   /></a>&nbsp;
                        <a href="{!'mailto:' + v.OwnerUser.Vertretung__c.Email}"><lightning:icon iconName="action:email" size="xx-small" alternativeText="E-Mail" title="E-Mail" /></a>&nbsp;
                        <a href="{!v.OwnerUser.Vertreter__c.Link_BookingTime__c}" target="_blank"><lightning:icon iconName="action:new_event" size="xx-small" alternativeText="BookingTime" title="BookingTime" /></a> 
                    </div>
                    
                </div>
                   
            </lightning:layoutItem>
              </aura:if>

 
Hello, I tried to make a test class for my apex but I still get errors.
Could you give me some support:

Apex class
public class Kampagne_Brief{
    
    public string camId {get;set;}
    
    @InvocableMethod(Label = 'Kampagne_Brief' description='')  
    
    public static void Kampagne_Brief(List<Id> CampaignId) {
        
        string camName = [SELECT Id, Name FROM Campaign WHERE Id =: CampaignId.get(0) LIMIT 1].Name;
        String strDate = String.valueOf(System.now().dateGmt()); // FORMAT YYYY-MM-DD
        // String strDate = System.now().format('yyyyMMdd'); // FORMAT YYYYMMDD
        
        PageReference page = Page.Kampagne_Brief_PDF;
        
        page.getParameters().put('Id', CampaignId.get(0));
        
        string camId= page.getParameters().put('Id', CampaignId.get(0));
        // string camName = page.getParameters().put('Campaign.Name', CampaignId.get(0));
        Blob contentBlob = page.getContentAsPDF();
        
        ContentVersion cv = new ContentVersion();
        cv.VersionData = contentBlob;
        cv.Title = strDate + '_' + camName;
        //    cv.Title =  System.today().year() + '_' + System.today().month() + '_' + System.today().day() + '_' + 'Serienbrief_'+ camName;
        cv.PathOnClient =  strDate + '_' + camName + '.pdf';
        //    cv.PathOnClient =  System.today().year() + '_' + System.today().month()  + '_' + System.today().day() + '_' + 'Serienbrief.pdf';
        cv.Vertraulichkeitsstufe__c = 'Intern';
        cv.Dokumentenklasse__c ='Anderes Dokument (nicht aufbewahrungspflichtig)';
        insert cv;
        
        cv = [SELECT Id, ContentDocumentId FROM ContentVersion WHERE Id = :cv.Id LIMIT 1];
        
        ContentDocumentLink cdl = new ContentDocumentLink();
        cdl.ContentDocumentId = cv.ContentDocumentId;
        cdl.ShareType = 'I';
        cdl.LinkedEntityId = camId;
        insert cdl;
    }
}

My test class to this point:
I get the error message: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [LinkedEntityId]: [LinkedEntityId]
 
@isTest 
public with sharing class Kampagnen_Brief_Test  {        
    static testmethod void contentDocumentTest()        {  
            
Campaign cam                        = new Campaign();
        cam.Name                            = 'Test Briefkampagne';
        cam.RecordTypeId                    = '0127a000001lOti';
        cam.IsActive                        = True;
        insert cam;

        
        ContentVersion cv = new ontentVersion();
        cv.Title = '2022-03-10_John Campaign';
        cv.PathOnClient = '2022-03-10_John Campaign.pdf';
        cv.VersionData = Blob.valueOf('Test Content');
        cv.IsMajorVersion = true;
        cv.Vertraulichkeitsstufe__c = 'Intern';
        cv.Dokumentenklasse__c ='Anderes Dokument (nicht aufbewahrungspflichtig)';
        Insert cv;
        ContentVersion contentVersion_2 = [SELECT Id, Title, ContentDocumentId 
                                           FROM ContentVersion WHERE Id = :cv.Id LIMIT 1];   
        ContentDocumentLink contentlink = new ContentDocumentLink();
        
        contentlink.contentdocumentid = contentVersion_2.contentdocumentid;
        contentlink.ShareType = 'V';
        insert contentlink;
        Kampagne_Brief KB = new Kampagne_Brief();             
        
    }
    
    
}

 
Hello, I have now tried for some time to create a screen flow thatgets the campaign Id to set the campaign to completed and create a PDF and stores it in the Campaign files. The only problem I have is, that I do not know how to get the campaign Id into my apex Class Invocable Method. Could you tell me how to implement a InvocableVariable or something like that, so I can insert the record Id into the class?

The Apex class:
 
public class SerienbriefSpeichern{


        
@InvocableMethod(Label = 'Serienbrief' description='')  
public static void Serienbriefspeichern() {

 
    
     PageReference page = Page.Campaign_PDF;
    
     Blob contentBlob = !Test.isRunningTest() ? page.getContentAsPDF() : Blob.valueOf('Hardcoded sample text for Test class');
     
    ContentVersion cv = new ContentVersion();
    cv.VersionData = contentBlob;
    cv.Title =  System.today().year() + '_' + System.today().month() + '_Serienbrief';
    cv.PathOnClient =  System.today().day() + '_' + System.today().month() + 'Serienbrief.pdf';
    cv.Vertraulichkeitsstufe__c = 'Intern';
    cv.Dokumentenklasse__c ='Anderes Dokument (nicht aufbewahrungspflichtig)';
    insert cv;                
    cv = [SELECT Id, ContentDocumentId FROM ContentVersion WHERE Id = :cv.Id LIMIT 1];
        
    ContentDocumentLink cdl = new ContentDocumentLink();
    cdl.ContentDocumentId = cv.ContentDocumentId;
    cdl.ShareType = 'I';
    cdl.LinkedEntityId = '7017a000000pVQnAAM';
    insert cdl;
    }
    }

 
Hello, could you help me with test class for my apex?
 
public class MonthlyReport4FDB{
 
@InvocableMethod(Label = 'MonthlyReport4FDB' description='')  
public static void MonthlyReport4FDB() {

     PageReference page = Page.MonthlyReport;
    
     Blob contentBlob = page.getContentAsPDF();
     
    ContentVersion cv = new ContentVersion();
    cv.VersionData = contentBlob;
    cv.Title =  System.today().year() + '_' + System.today().month() + '_FDB_Alle_Aktivitaeten';
    cv.PathOnClient =  System.today().year() + '_' + System.today().month() + '_FDB_Alle_Aktivitaeten.pdf';
    cv.Vertraulichkeitsstufe__c = 'Intern';
    cv.Dokumentenklasse__c ='Anderes Dokument (nicht aufbewahrungspflichtig)';
    insert cv;                
    cv = [SELECT Id, ContentDocumentId FROM ContentVersion WHERE Id = :cv.Id LIMIT 1];
        
    ContentDocumentLink cdl = new ContentDocumentLink();
    cdl.ContentDocumentId = cv.ContentDocumentId;
    cdl.ShareType = 'I';
    cdl.LinkedEntityId = '001b000000Zps12AAB';
    insert cdl;
    }
}

 
Hello, I have a report that I need to automatically save as a pdf at the last day of the month at 23:59 every month. But the pdf schould only include the records which where created in the month, so it is an actual month-report.

This pdf should be created automatically at 23:59 at the last day so i dont have to do anything and be save at files of a custom object

Hello, I have build a task datatable component and added the Who.Name as a column. It is working fine when the Who.Name field has content in it, otherwise I get an error message when leaving the field empty. Could you give me a solution for it?

User-added image


My code:

APEX
//ÜBERFÄLLIG - Abfrage Tasks, wo das Activity Date abgelaufen und der Status "Not Completed" ist//
@AuraEnabled
public static List<Task> loadTasks(Id recordId){
    string userId = UserInfo.getUserId();
    return[SELECT Subject, Who.Name, WhoId, ActivityDate, Status FROM Task WHERE ActivityDate< TODAY AND OwnerId=:userId AND Status !='Completed'];
}


JS
 
component.set('v.mycolumns', [
            {label: 'Thema', fieldName: 'SubjectName', type: 'url',
            typeAttributes: {label: { fieldName: 'Subject' }, target: '_blank'}},
                 {label: 'Name', fieldName: 'whoName', type: 'text',
            typeAttributes: {label: { fieldName: 'Who.Name' }, target: '_blank'}},
        ]);
        var action = component.get("c.loadTasks");
            action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                var records =response.getReturnValue();
                records.forEach(function(record){
                   
                    record.SubjectName = '/'+record.Id;
                    record.whoName = record.Who.Name
                });
                component.set("v.tasks", records);
            }
        });
        $A.enqueueAction(action);

 
Hello friends, I have a task datatable component and added the Who.Name as a column. the problem is, that now I do get error messages whenever there is a task where Who.Name is empty. Could you give me a solution for it?

User-added image
My code:

APEX
@AuraEnabled
public static List<Task> loadTasks3(Id recordId){
    string userId = UserInfo.getUserId();
    return[SELECT Subject, Who.Name, ActivityDate, Status FROM Task WHERE ActivityDate = TOMORROW AND OwnerId=:userId AND Status !='Completed'];
}



JS
component.set('v.mycolumns', [
            {label: 'Thema', fieldName: 'SubjectName', type: 'url',
            typeAttributes: {label: { fieldName: 'Subject' }, target: '_blank'}},
                 {label: 'Name', fieldName: 'whoName', type: 'text',
            typeAttributes: {label: { fieldName: 'Who.Name' }, target: '_blank'}},
        ]);
        var action = component.get("c.loadTasks");
            action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                var records =response.getReturnValue();
                records.forEach(function(record){
                   
                    record.SubjectName = '/'+record.Id;
                    record.whoName = record.Who.Name
                });
                component.set("v.tasks", records);
            }
        });
        $A.enqueueAction(action);

 
Hello, I want to get the Who.Name in a datatable, but I struggle with it due to the value not displaying in my datatable component.
I'm quite confident that my query in my apex class is working:
@AuraEnabled
public static List<Task> loadTasks2(Id recordId){
    string userId = UserInfo.getUserId();
    return[SELECT Subject, Who.Name, ActivityDate, Status FROM Task WHERE ActivityDate = TODAY AND OwnerId=:userId AND Status !='Completed'];
}

I think I made a mistake in the Datatable Controller. Could you look in it and tell me what to change, so the Who.Name is shown?

Controller:
component.set('v.mycolumns2', [
            {label: 'Thema', fieldName: 'Subject', type: 'url',
            typeAttributes: {label: { fieldName: 'Subject' }, target: '_blank'}},             
            {label: 'Name', fieldName: 'WhoName', type: 'lookup',
            typeAttributes: {label: { fieldName: 'Who.Name' }, target: '_blank'}},
        ]);
        var action = component.get("c.loadTasks2");
        
        
        
        var whatId = component.get("v.recordId");
        action.setParams({
            "recordId":whatId
        });
          
            action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                var records =response.getReturnValue();
                records.forEach(function(record){
                   
                    record.SubjectName = '/'+record.Id;
                    
                });
                component.set("v.tasks2", records);
            }
        });
        $A.enqueueAction(action);

 
Hello, I have a Visualforce template. I want to use an apex class with PageReference.getContentAsPDF() to create a pdf through a flow with the VF template. Could you give me an example of the Apex class to use for my "Visualforce code" that I can add to a flow to create a pdf. (I want to achive, that the fields of the visualforce like (!Account.Name) are filled with screen flow inputs)

Thank you in advance.
Greetings
Jonathan

My Visualforce code:
<apex:page standardController="Account" renderAs="pdf"  >
    
   
    
    <h1>Welcome to APP!</h1>
        
        <p>Thank you, <b><apex:outputText value=" {!Account.Name}"/></b>, for 
            working with APP.</p>
        
        <p>Your account details are:</p>
        
        <table>
            <tr><th>Account Name</th>
                <td><apex:outputText value="{!Account.Name}"/></td>
            </tr>
            <tr><th>Account Rep</th>
                <td><apex:outputText value="{!Account.Owner.Name}"/></td>
            </tr>
            <tr><th>Customer Since</th>
                <td><apex:outputText value="{0,date,long}">
                    <apex:param value="{!Account.CreatedDate}"/>
                    </apex:outputText></td>
            </tr>
        </table>
       
</apex:page>


 
Hello, my chefs wants me to inform myself about the steps we need to make befor the CORS release update.
I already looked if we have some URL under setup->CORS, but it was not the case.
Do I have to add every link that I have in salesforce to a page outside?

We use the sales cloud and never had any CORS problem so I am not sure about any needed changes to our org :D 

Greetings
Jonathan