-
ChatterFeed
-
0Best Answers
-
4Likes Received
-
0Likes Given
-
240Questions
-
87Replies
Test class for custom object Apex class
Hello, I need a test class for my apex class. I tried it but failed. Could you help me please?
public class MediathekSearchController2 { @AuraEnabled(cacheable=true) public static List<List<sObject>> getSearchResult(String searchKey, String TypValue, String ZielgruppeValue, String ThemaValue){ String findStr = searchKey+'*'; String AWhere111 = ' AND Typ__c = \''+ TypValue + '\''; Boolean isEmptySearch = String.isEmpty(searchKey); String findClause; system.debug('Das searchKey ist: ' + findStr); List <String> WhereClauses = new List <String>(); IF (searchKey !=null) { IF (ThemaValue !=null && ThemaValue !='Alle') { WhereClauses.Add('Thema__c = \'' + ThemaValue + '\''); } IF (TypValue !=null && TypValue !='Alle') { WhereClauses.Add('Typ__c = \'' + TypValue + '\''); } IF (ZielgruppeValue !=null && ZielgruppeValue !='Alle') { WhereClauses.Add('Zielgruppe__c = \'' + ZielgruppeValue + '\''); } } String WhereClause = String.join(WhereClauses, ' AND '); IF (WhereClauses.size()>0){ findClause = 'FIND \'' + findStr + '\' IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Mediathek_ID_Long__c, Name, Bezeichnung__c, ContentDocumentID__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Inaktiv__c=false AND ' + WhereClause + ')'; }else{ findClause = 'FIND \'' + findStr + '\' IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Mediathek_ID_Long__c, Name, Bezeichnung__c, ContentDocumentID__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Inaktiv__c=false)'; } system.debug('findcluase: ' +findclause); // String findClause = 'FIND\'' + findStr + '\' IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Mediathek_ID_Long__c, Name, Bezeichnung__c, ContentDocumentID__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Inaktiv__c=false)'; // List <String> Find2 = new List <String>(findClause); List<List<sObject>> searchResult2 = search.query(findClause); system.debug('Das searchResult2 ist: ' + searchResult2); String SQL = searchResult2 + WhereClause; system.debug('Der Query ist: ' + SQL); return searchResult2; } @AuraEnabled public static Map<String, String> getTypFieldValue(){ Map<String, String> options = new Map<String, String>(); Schema.DescribeFieldResult fieldResult = Mediathek__c.Typ__c.getDescribe(); List<Schema.PicklistEntry> pValues = fieldResult.getPicklistValues(); for (Schema.PicklistEntry p: pValues) { options.put(p.getValue(), p.getLabel()); } return options; } @AuraEnabled public static Map<String, String> getThemaFieldValue(){ Map<String, String> options = new Map<String, String>(); Schema.DescribeFieldResult fieldResult = Mediathek__c.Thema__c.getDescribe(); List<Schema.PicklistEntry> pValues = fieldResult.getPicklistValues(); for (Schema.PicklistEntry p: pValues) { options.put(p.getValue(), p.getLabel()); } return options; } @AuraEnabled public static Map<String, String> getZielgruppeFieldValue(){ Map<String, String> options = new Map<String, String>(); Schema.DescribeFieldResult fieldResult = Mediathek__c.Zielgruppe__c.getDescribe(); List<Schema.PicklistEntry> pValues = fieldResult.getPicklistValues(); for (Schema.PicklistEntry p: pValues) { options.put(p.getValue(), p.getLabel()); } return options; } }
- Jonathan Wolff 7
- February 22, 2023
- Like
- 0
Create String variable with SQL Where Clause
Hello, I would like to create a string variable that contains a Where-clause. I tried the following:
String AWhereClause= 'AND Typ__c = 'Infobroschüre'';
Unfortunatly that way does not work. Can you give me an solution for that?
String AWhereClause= 'AND Typ__c = 'Infobroschüre'';
Unfortunatly that way does not work. Can you give me an solution for that?
- Jonathan Wolff 7
- February 22, 2023
- Like
- 0
Error: Method does not exist or incorrect signature: void query(List<List<SObject>>) from the type Database
Hello, I tried to create a sosl spex class, but get the error: Method does not exist or incorrect signature: void query(List<List<SObject>>) from the type Database
My code is the following:
My code is the following:
public class MediathekSearchController2 { @AuraEnabled(cacheable=true) public static List<List<sObject>> getSearchResult(String searchKey, String TypValue, String ZielgruppeValue, String ThemaValue){ String findStr = '*'+searchKey+'*'; Boolean isEmptySearch = String.isEmpty(searchKey); system.debug('Das searchKey ist: ' + findStr); List<List<SObject>> searchResult2 = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Mediathek_ID_Long__c, Name, Bezeichnung__c, ContentDocumentID__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Inaktiv__c=false)]; system.debug('Das searchResult2 ist: ' + searchResult2); List<List<sObject>> searchResult = Database.query(searchResult2); system.debug('searchKey ' + searchResult); return searchResult; } }
- Jonathan Wolff 7
- February 20, 2023
- Like
- 0
SOSL results in Apex class dont work
Hello,
I want to create a component to show records of a custom object that include my searchkey. Unfortunatly my code does not show any results. Could you gelp me with this topic?
My Logs are these:
I want to create a component to show records of a custom object that include my searchkey. Unfortunatly my code does not show any results. Could you gelp me with this topic?
My Logs are these:
public with sharing class MediathekSearchController { @AuraEnabled(cacheable=true) public static List<sObject> getSearchResult(String searchKey, String TypValue, String ZielgruppeValue, String ThemaValue){ String findStr = '*'+searchKey+'*'; Boolean isEmptySearch = String.isEmpty(searchKey); system.debug('Das searchKey ist: ' + findStr); String searchResult2 = 'FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Mediathek_ID_Long__c, Name, Bezeichnung__c, ContentDocumentID__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Thema__c=:ThemaValue AND Typ__c=:TypValue AND Zielgruppe__c=:ZielgruppeValue AND Inaktiv__c=false)'; system.debug('Das searchResult2 ist: ' + searchResult2); List <String> WhereClauses = new List <String>(); IF (searchKey !=null) { WhereClauses.Add(' WHERE (Bezeichnung__c LIKE \'%' + searchKey + '%\' OR Typ__c LIKE \'%' + searchKey + '%\')'); } IF (ThemaValue !=null && ThemaValue !='Alle') { WhereClauses.Add('Thema__c = \'' + ThemaValue + '\''); } IF (TypValue !=null && TypValue !='Alle') { WhereClauses.Add('Typ__c = \'' + TypValue + '\''); } IF (ZielgruppeValue !=null && ZielgruppeValue !='Alle') { WhereClauses.Add('Zielgruppe__c = \'' + ZielgruppeValue + '\''); } String WhereClause = String.join(WhereClauses, ' AND '); String SQL = searchResult2 + WhereClause; system.debug('Der Query ist: ' + SQL); List<sObject> searchResult = Database.query(searchResult2); system.debug('searchKey ' + searchResult); return searchResult; }
- Jonathan Wolff 7
- February 20, 2023
- Like
- 0
No results for SOSL List with where clauses
Hello,
I try to build a Searchbar component to give out a List of custom object (Mediathek__c) records. I try to use an sosl to use a keyword and show the results. Unfortunatly, I do not get any records for my searchKey, even tough the debug says, tat the searchkey enters right into the apex class. Could you help me to improve my code to get a proper List. In addition I get the error: 'unexpected toke:Find' in my debug.
I try to build a Searchbar component to give out a List of custom object (Mediathek__c) records. I try to use an sosl to use a keyword and show the results. Unfortunatly, I do not get any records for my searchKey, even tough the debug says, tat the searchkey enters right into the apex class. Could you help me to improve my code to get a proper List. In addition I get the error: 'unexpected toke:Find' in my debug.
public with sharing class MediathekSearchController { @AuraEnabled(cacheable=true) public static List<sObject> getSearchResult(String searchKey, String TypValue, String ZielgruppeValue, String ThemaValue){ String findStr = '*'+searchKey+'*'; Boolean isEmptySearch = String.isEmpty(searchKey); system.debug('Das searchKey ist: ' + findStr); String searchResult2 = 'FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Mediathek_ID_Long__c, Name, Bezeichnung__c, ContentDocumentID__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Thema__c=:ThemaValue AND Typ__c=:TypValue AND Zielgruppe__c=:ZielgruppeValue AND Inaktiv__c=false)'; system.debug('Das searchResult2 ist: ' + searchResult2); List <String> WhereClauses = new List <String>(); IF (searchKey !=null) { WhereClauses.Add(' WHERE (Bezeichnung__c LIKE \'%' + searchKey + '%\' OR Typ__c LIKE \'%' + searchKey + '%\')'); } IF (ThemaValue !=null && ThemaValue !='Alle') { WhereClauses.Add('Thema__c = \'' + ThemaValue + '\''); } IF (TypValue !=null && TypValue !='Alle') { WhereClauses.Add('Typ__c = \'' + TypValue + '\''); } IF (ZielgruppeValue !=null && ZielgruppeValue !='Alle') { WhereClauses.Add('Zielgruppe__c = \'' + ZielgruppeValue + '\''); } String WhereClause = String.join(WhereClauses, ' AND '); //List<List<sObject>> searchResult = Search.query(SelectClause); String SQL = searchResult2 + WhereClause; system.debug('Der Query ist: ' + SQL); List<sObject> searchResult = Database.query(searchResult2); system.debug('searchKey ' + searchResult); return searchResult; }
- Jonathan Wolff 7
- February 20, 2023
- Like
- 0
Can get return results for search query
Hello, i tried to create apex code to give out a list of records from the custom object Mediathek__c. I get a searchKey from the component and would like to create a list based on the searchkey Unfortunatly I do not get any results out of it. Could you tell me what to change about my code to get the List of search results?
Kind regards,
Jonathan
Kind regards,
Jonathan
@AuraEnabled(cacheable=true) public static List<List<sObject>> getSearchResult(String searchKey, String TypValue, String ZielgruppeValue, String ThemaValue){ String findStr = '*'+searchKey+'*'; Boolean isEmptySearch = String.isEmpty(searchKey); String SelectClause = 'FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Mediathek_ID_Long__c, Name, Bezeichnung__c, ContentDocumentID__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Thema__c=:ThemaValue AND Typ__c=:TypValue AND Zielgruppe__c=:ZielgruppeValue AND Inaktiv__c=false)'; //String SelectClause = 'SELECT Id, Mediathek_ID_Long__c, Thema__c, ContentDocumentID__c, ContentVersionId__c, Thumbnail_Image__c,Thumbnail_Preview2__c, Name, Bezeichnung__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c FROM Mediathek__c'; List <String> WhereClauses = new List <String>(); IF (searchKey !=null) { WhereClauses.Add(' WHERE (Bezeichnung__c LIKE \'%' + searchKey + '%\' OR Typ__c LIKE \'%' + searchKey + '%\')'); } IF (ThemaValue !=null && ThemaValue !='Alle') { // WhereClauses.Add('Status__c = \'' + SelectedStatus + '\''); WhereClauses.Add('Thema__c = \'' + ThemaValue + '\''); } IF (TypValue !=null && TypValue !='Alle') { WhereClauses.Add('Typ__c = \'' + TypValue + '\''); } IF (ZielgruppeValue !=null && ZielgruppeValue !='Alle') { WhereClauses.Add('Zielgruppe__c = \'' + ZielgruppeValue + '\''); } String.join(WhereClauses, ' AND '); String WhereClause = String.join(WhereClauses, ' AND '); List<List<sObject>> searchResult = Search.query(SelectClause); system.debug('The searchResult is: ' + searchResult); return searchResult; }
- Jonathan Wolff 7
- February 15, 2023
- Like
- 0
Cant find specific record in search sosl query
Hello, I created a searchbar component to show records that include at least one field with the input. The problem i have is, that
When I insert 'Ar' it should find the records that have 'arbeitgeber' in the field Zielgruppe, bc it contains 'Ar'.
Unfortunatly I dont find the Record 'Equal Pension, even tough it contains Ar in the field Zielgruppe.
Could you look over my code and give me an advice what to change so the problem does not occure
When I insert 'Ar' it should find the records that have 'arbeitgeber' in the field Zielgruppe, bc it contains 'Ar'.
Unfortunatly I dont find the Record 'Equal Pension, even tough it contains Ar in the field Zielgruppe.
Could you look over my code and give me an advice what to change so the problem does not occure
public with sharing class MediathekSearchController { @AuraEnabled(cacheable=true) public static List<sObject> getSearchResult(String searchKey, String TypValue, String ZielgruppeValue, String ThemaValue){ String findStr = ' '+searchKey+' '; Boolean isEmptySearch = String.isEmpty(searchKey); system.debug('searchKey ' + searchKey); system.debug('findStr ' + findStr); system.debug('KategorieValue' + TypValue); system.debug('ZielgruppeValue' + ZielgruppeValue); system.debug('ThemaValue' + ThemaValue); List<List<sObject>> searchResult; if(ThemaValue == 'Alle' && ZielgruppeValue == 'Alle' && TypValue == 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Mediathek_ID_Long__c, Thema__c, ContentDocumentID__c, ContentVersionId__c, Thumbnail_Image__c,Thumbnail_Preview2__c, Name, Bezeichnung__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c Where Inaktiv__c=false)]; } else if(ThemaValue == 'Alle' && ZielgruppeValue == 'Alle' && TypValue != 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Mediathek_ID_Long__c, Name, Bezeichnung__c, ContentDocumentID__c, Thumbnail_Image__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Typ__c=:TypValue AND Inaktiv__c=false)]; } else if(ThemaValue == 'Alle' && ZielgruppeValue != 'Alle' && TypValue == 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Mediathek_ID_Long__c, Name, Bezeichnung__c, Typ__c, ContentDocumentID__c, Thumbnail_Image__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Zielgruppe__c=:ZielgruppeValue AND Inaktiv__c=false)]; } else if(ThemaValue != 'Alle' && ZielgruppeValue == 'Alle' && TypValue == 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Name, Mediathek_ID_Long__c, Bezeichnung__c, Typ__c, ContentDocumentID__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Thema__c=:ThemaValue AND Inaktiv__c=false)]; } else if(ThemaValue == 'Alle' && ZielgruppeValue != 'Alle' && TypValue != 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Name, Mediathek_ID_Long__c, Bezeichnung__c, Typ__c, ContentDocumentID__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Typ__c=:TypValue AND Zielgruppe__c=:ZielgruppeValue AND Inaktiv__c=false)]; } else if(ThemaValue != 'Alle' && ZielgruppeValue != 'Alle' && TypValue == 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Name, Mediathek_ID_Long__c, Bezeichnung__c, Typ__c, ContentDocumentID__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Thema__c=:ThemaValue AND Zielgruppe__c=:ZielgruppeValue AND Inaktiv__c=false)]; } else if(ThemaValue != 'Alle' && ZielgruppeValue == 'Alle' && TypValue != 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Name, Mediathek_ID_Long__c, Bezeichnung__c, ContentDocumentID__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Thema__c=:ThemaValue AND Typ__c=:TypValue AND Inaktiv__c=false)]; } else if(ThemaValue != 'Alle' && ZielgruppeValue != 'Alle' && TypValue != 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Mediathek_ID_Long__c, Name, Bezeichnung__c, ContentDocumentID__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Thema__c=:ThemaValue AND Typ__c=:TypValue AND Zielgruppe__c=:ZielgruppeValue AND Inaktiv__c=false)]; } return searchResult; } @AuraEnabled public static Map<String, String> getTypFieldValue(){ Map<String, String> options = new Map<String, String>(); Schema.DescribeFieldResult fieldResult = Mediathek__c.Typ__c.getDescribe(); List<Schema.PicklistEntry> pValues = fieldResult.getPicklistValues(); for (Schema.PicklistEntry p: pValues) { options.put(p.getValue(), p.getLabel()); } return options; } @AuraEnabled public static Map<String, String> getThemaFieldValue(){ Map<String, String> options = new Map<String, String>(); Schema.DescribeFieldResult fieldResult = Mediathek__c.Thema__c.getDescribe(); List<Schema.PicklistEntry> pValues = fieldResult.getPicklistValues(); for (Schema.PicklistEntry p: pValues) { options.put(p.getValue(), p.getLabel()); } return options; } @AuraEnabled public static Map<String, String> getZielgruppeFieldValue(){ Map<String, String> options = new Map<String, String>(); Schema.DescribeFieldResult fieldResult = Mediathek__c.Zielgruppe__c.getDescribe(); List<Schema.PicklistEntry> pValues = fieldResult.getPicklistValues(); for (Schema.PicklistEntry p: pValues) { options.put(p.getValue(), p.getLabel()); } return options; } }
- Jonathan Wolff 7
- February 06, 2023
- Like
- 0
Rewrite Component with where-clause and String.join
Hello, I have an apex class in which I change the soql with picklist fields from component. I would like to change the style of the class so it is with a where clause and a string join. Right now it is like that:
The style of how i would like it is like that:
public with sharing class MediathekSearchController { @AuraEnabled(cacheable=true) public static List<List<sObject>> getSearchResult(String searchKey, String TypValue, String ZielgruppeValue, String ThemaValue){ String findStr = '*'+searchKey+'*'; Boolean isEmptySearch = String.isEmpty(searchKey); system.debug('searchKey ' + searchKey); system.debug('findStr ' + findStr); system.debug('KategorieValue' + TypValue); system.debug('ZielgruppeValue' + ZielgruppeValue); system.debug('ThemaValue' + ThemaValue); List<List<sObject>> searchResult; if(ThemaValue == 'Alle' && ZielgruppeValue == 'Alle' && TypValue == 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Mediathek_ID_Long__c, Thema__c, ContentDocumentID__c, ContentVersionId__c, Thumbnail_Image__c,Thumbnail_Preview2__c, Name, Bezeichnung__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c Where Inaktiv__c=false)]; } else if(ThemaValue == 'Alle' && ZielgruppeValue == 'Alle' && TypValue != 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Mediathek_ID_Long__c, Name, Bezeichnung__c, ContentDocumentID__c, Thumbnail_Image__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Typ__c=:TypValue AND Inaktiv__c=false)]; } else if(ThemaValue == 'Alle' && ZielgruppeValue != 'Alle' && TypValue == 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Mediathek_ID_Long__c, Name, Bezeichnung__c, Typ__c, ContentDocumentID__c, Thumbnail_Image__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Zielgruppe__c=:ZielgruppeValue AND Inaktiv__c=false)]; } else if(ThemaValue != 'Alle' && ZielgruppeValue == 'Alle' && TypValue == 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Name, Mediathek_ID_Long__c, Bezeichnung__c, Typ__c, ContentDocumentID__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Thema__c=:ThemaValue AND Inaktiv__c=false)]; } else if(ThemaValue == 'Alle' && ZielgruppeValue != 'Alle' && TypValue != 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Name, Mediathek_ID_Long__c, Bezeichnung__c, Typ__c, ContentDocumentID__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Typ__c=:TypValue AND Zielgruppe__c=:ZielgruppeValue AND Inaktiv__c=false)]; } else if(ThemaValue != 'Alle' && ZielgruppeValue != 'Alle' && TypValue == 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Name, Mediathek_ID_Long__c, Bezeichnung__c, Typ__c, ContentDocumentID__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Thema__c=:ThemaValue AND Zielgruppe__c=:ZielgruppeValue AND Inaktiv__c=false)]; } else if(ThemaValue != 'Alle' && ZielgruppeValue == 'Alle' && TypValue != 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Name, Mediathek_ID_Long__c, Bezeichnung__c, ContentDocumentID__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Thema__c=:ThemaValue AND Typ__c=:TypValue AND Inaktiv__c=false)]; } else if(ThemaValue != 'Alle' && ZielgruppeValue != 'Alle' && TypValue != 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Mediathek_ID_Long__c, Name, Bezeichnung__c, ContentDocumentID__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Thema__c=:ThemaValue AND Typ__c=:TypValue AND Zielgruppe__c=:ZielgruppeValue AND Inaktiv__c=false)]; } return searchResult; }
The style of how i would like it is like that:
String SelectClause = 'SELECT Id, OwnerId, Name, BillingCity, NumberOfEmployees, Owner.Name, (SELECT LastModifiedDate FROM Opportunities ORDER BY LastModifiedDate DESC Limit 1) FROM Account'; String SelectClause = 'SELECT Id, OwnerId, Name, BillingCity, NumberOfEmployees, Owner.Name, (SELECT LastModifiedDate FROM Opportunities ORDER BY LastModifiedDate DESC Limit 1) FROM Account'; String LimitClause = ' ORDER BY Name LIMIT 1000'; String CountSelectClause = 'SELECT Count() FROM Account'; String CountLimitClause = ' LIMIT 1000'; List <String> WhereClauses = new List <String>(); IF (!isEmptyStand) { IF (SelectedStand == 'GREEN') { WhereClauses.Add('Id IN (SELECT AccountId FROM Opportunity WHERE LastModifiedDate = LAST_N_DAYS:60)'); } ELSE IF (SelectedStand == 'YELLOW') { WhereClauses.Add('Id IN (SELECT AccountId FROM Opportunity WHERE LastModifiedDate < LAST_N_DAYS:60 AND LastModifiedDate = LAST_N_DAYS:180)'); } ELSE IF (SelectedStand == 'RED') { WhereClauses.Add('Id IN (SELECT AccountId FROM Opportunity WHERE LastModifiedDate < LAST_N_DAYS:180)'); } ELSE IF (SelectedStand == 'LEER') { WhereClauses.Add('Id NOT IN (SELECT AccountId FROM Opportunity)'); } ELSE IF (SelectedStand == 'MIN1') { WhereClauses.Add('Id IN (SELECT AccountId FROM Opportunity)'); } } IF (!isEmptySearch) { WhereClauses.Add('Name LIKE \'' + SearchStringConvert + '\''); } IF (!isEmptyStatus) { WhereClauses.Add('Status__c = \'' + SelectedStatus + '\''); } IF (!isEmptyUser && SelectedUserId.contains('Team')) { WhereClauses.add('Team_Unternehmen__c = \'' + SelectedUserId + '\''); } IF (!isEmptyUser && !SelectedUserId.contains('Team')) { WhereClauses.Add('OwnerId = \'' + SelectedUserId + '\''); } String WhereClause = ' WHERE ' + String.join(WhereClauses, ' AND '); String SQL = SelectClause + WhereClause + LimitClause; String SQLCount = CountSelectClause + WhereClause + CountLimitClause; System.Debug('>>>> the value of SQL is ' + SQL); System.Debug('>>>> the value of SQL is ' + SQLCount); List <Account> Acc = Database.query(SQL);
- Jonathan Wolff 7
- January 27, 2023
- Like
- 0
Code adjustments to get lightning:select options from custom object picklist
Hello, I have 3 lightning:select regions in my component. They display the options from picklists in my custom object Mediathek__c. Could you tell me how to get the values from the picklists? The picklist fields are Typ__c, Zielgruppe__c and Thema__c.
My code for the component is the following:
Component
Controller
Apex
My code for the component is the following:
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}"/> <!-- <aura:handler name="change" value="{!v.searchKey}" action="{!c.valueChangeValidation}"/> --> <!-- attributes --> <aura:attribute name="showSearchResults" type="Boolean" default="false"/> <aura:attribute name="searchKey" type="String" default=""/> <aura:attribute name="mediathekList" type="List" default="Mediathek[]"/> <aura:attribute name="mediathekColumns" type="List"/> <aura:attribute name="accL" type="List"/> <aura:attribute name="TypValue" type="String" default="Alle"/> <aura:attribute name="ZielgruppeValue" type="String" default="Alle"/> <aura:attribute name="ThemaValue" type="String" default="Alle"/> <aura:attribute name="tooltip" type="boolean" default="false" /> <!-- <div class= "slds-box slds-p-top_none slds-p-bottom_none slds-p-right_none"> --> <div class= "slds-box slds-p-left_medium slds-p-bottom_medium"> <div class="slds-grid slds-wrap" > <div class="slds-size_12-of-12 "> <lightning:layout multipleRows="true"> <lightning:layoutItem size="7"> <lightning:input class="Eingabe" aura:id="inputField" name="searchKey" placeholder="Bitte geben Sie mindestens 2 Buchstaben ein, um zu suchen" value="{!v.searchKey}" onkeyup="{!c.search}" messageWhenBadInput="Es müssen mindestens 2 Zeichen eingegeben werden"/> </lightning:layoutItem> <lightning:layoutItem size="1"/> <lightning:layoutItem size="1"> <lightning:button variant="brand" label="Suchen" title="Search" onclick="{!c.search}" class="customButton1" /> </lightning:layoutItem> <lightning:layoutItem size="1"> <lightning:button variant="brand" label="Reset" title="Reset" onclick="{!c.reset}" class="customButton2" /> </lightning:layoutItem> <lightning:layoutItem size="2"/> <lightning:layoutItem size="3"> <lightning:select name="mediathekType" label="Select Mediathek Type" aura:id="acId"> <aura:iteration items="{!v.accL}" var="a" > <option value="{!a.Id}" text="{!a.Id}"/> </aura:iteration> </lightning:select> <!-- <lightning:select class="TypValue" aura:id="TypValue" name="Typ" label="Typ" required="false" value="{!v.TypValue}"> <option value="Alle">Alle</option> <option value="Formular">Formular</option> <option value="Merkblatt">Merkblatt</option> <option value="Flyer">Flyer</option> <option value="Infobroschüre">Infobroschüre</option> </lightning:select> --> </lightning:layoutItem> <lightning:layoutItem size="1"/> <lightning:layoutItem size="3"> <lightning:select class="ThemaValue" aura:id="ThemaValue" name="Thema" label="Thema" required="false" value="{!v.ThemaValue}"> <option value="Alle">Alle</option> <option value="Altersvorsorge">Altersvorsorge</option> <option value="AOK">AOK</option> <option value="Beratungstag">Beratungstag</option> <option value="Berufsunfähigkeit">Berufsunfähigkeit</option> <option value="Berufsunfähigkeit privat">Berufsunfähigkeit privat</option> <option value="bKV">bKV</option> <option value="BRSG">BRSG</option> <option value="Direktversicherung">Direktversicherung</option> <option value="Direktversicherung, ergänzende Berufsunfähigkeit, Berufsunfähigkeit">Direktversicherung, ergänzende Berufsunfähigkeit, Berufsunfähigkeit</option> <option value="Direktversicherung, Pensionsfonds">Direktversicherung, Pensionsfonds</option> <option value="Direktversicherung, Pensionskasse">Direktversicherung, Pensionskasse</option> <option value="Direktversicherung, Pensionskasse, Pensionsfonds">Direktversicherung, Pensionskasse, Pensionsfonds</option> <option value="englisches Material">englisches Material</option> <option value="FID FIR">FID FIR</option> <option value="Firmenversicherung (Gruppenvertrag)">Firmenversicherung (Gruppenvertrag)</option> <option value="Kundencall">Kundencall</option> <option value="Lebensversicherung privat">Lebensversicherung privat</option> <option value="Pensionsfonds">Pensionsfonds</option> <option value="Pensionskasse">Pensionskasse</option> <option value="Pensionszusage">Pensionszusage</option> <option value="privat">privat</option> <option value="PrivatRente, Schatzbrief Perspektive">PrivatRente, Schatzbrief Perspektive</option> <option value="Produktinfo">Produktinfo</option> <option value="rechtliche Unterlage">rechtliche Unterlage</option> <option value="Riester">Riester</option> <option value="Rückdeckungsversicherung FIR">Rückdeckungsversicherung FIR</option> <option value="Unterstützungskasse">Unterstützungskasse</option> <option value="Zeitwertkonto">Zeitwertkonto</option> <option value="Zusatzbausteine">Zusatzbausteine</option> </lightning:select> </lightning:layoutItem> <lightning:layoutItem size="1"/> <lightning:layoutItem size="3"> <lightning:select class="ZielgruppeValue text-left" aura:id="ZielgruppeValue" name="Zielgruppe" label="Zielgruppe" required="false" value="{!v.ZielgruppeValue}"> <option value="Alle">Alle</option> <option value="Arbeitgeber">Arbeitgeber</option> <option value="Arbeitnehmer">Arbeitnehmer</option> <option value="Berater">Berater</option> <option value="Verband">Verband</option> <option value="Arbeitgeber/Arbeitnehmer">Arbeitgeber/Arbeitnehmer</option> <option value="Azubi">Azubi</option> <option value="IGM">IGM</option> </lightning:select> </lightning:layoutItem> </lightning:layout> </div> </div> <div class="Ausgabe" style="margin-right:400px"> <aura:if isTrue="{!AND(v.showSearchResults, v.searchKey.length>1)}" > <!-- <lightning:layout multipleRows="true"> <lightning:layoutItem padding="around-large" size="12" > <lightning:datatable keyField="id" data="{!v.mediathekList}" columns="{!v.mediathekColumns}" hideCheckboxColumn="true"/> </lightning:layoutItem> </lightning:layout> --> <table class="slds-table slds-table--bordered slds-table--striped " style="width: 880px"> <thead> <tr> <th scope="col"><span class="slds-truncate">Suchergebnisse</span></th> <th scope="col"><span class="slds-truncate"></span></th> </tr> </thead> <tbody style="background-color:#F8F8F8"> <aura:iteration items="{!v.mediathekList}" var="media"> <tr style="background-color:#F8F8F8"> <td valign="top" style="background-color:#F8F8F8" > <a href="{!'/'+media.Mediathek_ID_Long__c}"><b>{!media.Bezeichnung__c}</b></a><br/> Typ: <b>{!media.Typ__c}</b><br/> Zielgruppe: <b>{!media.Zielgruppe__c}</b><br/> Umfang: <b>{!media.Umfang__c}</b> </td> <aura:if isTrue="{!not(empty(media.ContentVersionId__c))}" > <td style="background-color:#F8F8F8;"><img style="height:170px; border: 1px solid #555;" src="{!'/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId=' + media.ContentVersionId__c}" /> </td> </aura:if> <aura:if isTrue="{!empty(media.ContentVersionId__c)}" > <td style="background-color:#F8F8F8;"> </td> </aura:if> </tr> </aura:iteration> </tbody> </table> </aura:if> </div> </div> </aura:component>
Controller
({ /* 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, }, {label: 'Preview', fieldName: 'Bild_Preview__c', type: 'image', fixedWidth: 300, }, ]); 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); }, reset : function(component, event, helper) { helper.getSearchResultsFromApex(component, event, helper); component.set("v.showSearchResults",false); component.set("v.searchKey",null); component.set("v.TypValue",'Alle'); component.set("v.ZielgruppeValue",'Alle'); component.set("v.ThemaValue",'Alle'); } }) ({ 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: 'Thema', fieldName: 'Thema__c', type: 'text', fixedWidth: 112, }, {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); }, })
Apex
public with sharing class MediathekSearchController { @AuraEnabled(cacheable=true) public static List<List<sObject>> getSearchResult(String searchKey, String TypValue, String ZielgruppeValue, String ThemaValue){ String findStr = '*'+searchKey+'*'; Boolean isEmptySearch = String.isEmpty(searchKey); system.debug('searchKey ' + searchKey); system.debug('findStr ' + findStr); system.debug('KategorieValue' + TypValue); system.debug('ZielgruppeValue' + ZielgruppeValue); system.debug('ThemaValue' + ThemaValue); List<List<sObject>> searchResult; if(ThemaValue == 'Alle' && ZielgruppeValue == 'Alle' && TypValue == 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Mediathek_ID_Long__c, Thema__c, ContentDocumentID__c, ContentVersionId__c, Thumbnail_Image__c,Thumbnail_Preview2__c, Name, Bezeichnung__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c Where Inaktiv__c=false)]; } else if(ThemaValue == 'Alle' && ZielgruppeValue == 'Alle' && TypValue != 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Mediathek_ID_Long__c, Name, Bezeichnung__c, ContentDocumentID__c, Thumbnail_Image__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Typ__c=:TypValue AND Inaktiv__c=false)]; } else if(ThemaValue == 'Alle' && ZielgruppeValue != 'Alle' && TypValue == 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Mediathek_ID_Long__c, Name, Bezeichnung__c, Typ__c, ContentDocumentID__c, Thumbnail_Image__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Zielgruppe__c=:ZielgruppeValue AND Inaktiv__c=false)]; } else if(ThemaValue != 'Alle' && ZielgruppeValue == 'Alle' && TypValue == 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Name, Mediathek_ID_Long__c, Bezeichnung__c, Typ__c, ContentDocumentID__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Thema__c=:ThemaValue AND Inaktiv__c=false)]; } else if(ThemaValue == 'Alle' && ZielgruppeValue != 'Alle' && TypValue != 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Name, Mediathek_ID_Long__c, Bezeichnung__c, Typ__c, ContentDocumentID__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Typ__c=:TypValue AND Zielgruppe__c=:ZielgruppeValue AND Inaktiv__c=false)]; } else if(ThemaValue != 'Alle' && ZielgruppeValue != 'Alle' && TypValue == 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Name, Mediathek_ID_Long__c, Bezeichnung__c, Typ__c, ContentDocumentID__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Thema__c=:ThemaValue AND Zielgruppe__c=:ZielgruppeValue AND Inaktiv__c=false)]; } else if(ThemaValue != 'Alle' && ZielgruppeValue == 'Alle' && TypValue != 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Name, Mediathek_ID_Long__c, Bezeichnung__c, ContentDocumentID__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Thema__c=:ThemaValue AND Typ__c=:TypValue AND Inaktiv__c=false)]; } else if(ThemaValue != 'Alle' && ZielgruppeValue != 'Alle' && TypValue != 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Mediathek_ID_Long__c, Name, Bezeichnung__c, ContentDocumentID__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Thema__c=:ThemaValue AND Typ__c=:TypValue AND Zielgruppe__c=:ZielgruppeValue AND Inaktiv__c=false)]; } return searchResult; } }
- Jonathan Wolff 7
- January 20, 2023
- Like
- 0
Replace manually entered Lightning:select options with automatically populated through picklist
Hello, I have a lightning:select in which I entered all picklist values manually. So it looks like that:
Greetings,
Jonathan
<lightning:select class="ThemaValue" aura:id="ThemaValue" name="Thema" label="Thema" required="false" value="{!v.ThemaValue}"> <option value="Alle">Alle</option> <option value="Altersvorsorge">Altersvorsorge</option> <option value="AOK">AOK</option> <option value="Beratungstag">Beratungstag</option> <option value="Berufsunfähigkeit">Berufsunfähigkeit</option> <option value="bKV">bKV</option> <option </lightning:select>Unfortunatly there is a problem, that the values are based on a picklist on my custom object Mediathek named 'Thema__c'. Is there a way to get the values of the picklist as options in my lightning select?
Greetings,
Jonathan
- Jonathan Wolff 7
- January 18, 2023
- Like
- 0
fixed sorting in pagination list with wrapper class
Hello,
i have a requirement about my List with pagination that uses a wrapper class. I would like to standart order the records by date descending. I tried some code on the internet but i do get errors or it doesnt work. Could you please show me how to impleent it?
i have a requirement about my List with pagination that uses a wrapper class. I would like to standart order the records by date descending. I tried some code on the internet but i do get errors or it doesnt work. Could you please show me how to impleent it?
<aura:component controller="ApexActivityWrapper" implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" access="global"> <aura:attribute name="accountList" type="Object" /> <aura:attribute name="PaginationList" type="Object"/> <aura:attribute name="perPageSize" type="Integer" default="10"/> <aura:attribute name="totalRecords" type="Integer"/> <aura:attribute name="totalPages" type="Integer" default="0"/> <aura:attribute name="startValue" type="Integer" /> <aura:attribute name="endValue" type="Integer"/> <aura:attribute name="columns" type="List"/> <aura:attribute name="sortedBy" type="String"/> <aura:attribute name="sortedDirection" type="String"/> <aura:attribute name="isLastPage" type="Boolean"/> <aura:attribute name="currentPageNumber" type="Integer" default="1"/> <aura:handler name="init" action="{!c.doInit}" value="{!this}"/> <!-- Ergebnisse + Pagination--> <div class="slds-grid slds-grid_vertical"> <aura:if isTrue="{!not(empty(v.PaginationList))}"> <lightning:datatable data="{!v.PaginationList}" columns="{!v.columns}" keyField="Id" onsort="{!c.updateSorting}" sortedBy="{!v.sortedBy}" sortedDirection="{!v.sortedDirection}" hideCheckboxColumn="true" /> <aura:set attribute="else"> <div Style="text-align : center"> Keine Aktivitäten </div> </aura:set> </aura:if> <lightning:buttongroup> <lightning:button onclick="{!c.previous}" disabled="{!v.startValue == 0}" label="Previous" iconName='utility:back'/> <lightning:button onclick="{!c.next}" disabled="{!v.isLastPage}" label="Next" iconName='utility:forward'/> </lightning:buttongroup> </div> </aura:component>
({ doInit : function(component, event, helper) { 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(); component.set('v.accountList', response.getReturnValue()); console.log(component.get('v.accountList')); //total number of accounts recieved----------------------------------------- var lengthVar = component.get("v.accountList").length; console.log('length///'+lengthVar); component.set("v.totalRecords",lengthVar); //--------------------------------------------------------------------------- //number of records in each page--------------------------------------------- var perPage = component.get("v.perPageSize"); //--------------------------------------------------------------------------- var values=[]; console.log('perPage///'+perPage); //If total number of records are more than 5 or equals 5----------------------- if(lengthVar >= perPage){ for(var i=0;i<perPage;i++){ values.push(response.getReturnValue()[i]); } }//-------------------------------------------------------------------------- else{//If total number of records are lesser than 5-------------------------- for(var i=0;i<lengthVar;i++){ values.push(response.getReturnValue()[i]); } }//-------------------------------------------------------------------------- console.log('values///'+values); component.set("v.PaginationList",values); component.set("v.startValue",0); //if there are only 5 records or lesser than that in total------------------- if(lengthVar <= (component.get("v.startValue")+perPage)){ component.set("v.isLastPage",true); } component.set("v.endValue",component.get("v.startValue")+perPage-1); }); $A.enqueueAction(action); component.set('v.columns', [ {label: 'Status', fieldName: '', initialWidth: 50, cellAttributes: {iconName: {fieldName: 'StatusPicOut' } } }, //{label: "Datum", fieldName: 'DatumOut', sortable: true, type: "date", initialWidth: 80, typeAttributes: {month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", hour12: true } }, {label: "Datum", fieldName: 'DatumOut', sortable: true, type: "date", initialWidth: 110, typeAttributes: {day: '2-digit', month: '2-digit', year: '2-digit', hour: '2-digit', minute: '2-digit', hour12: false } }, {label: 'Art', fieldName: '', initialWidth: 60, cellAttributes: {iconName: {fieldName: 'ArtPicOut' } } }, {label: 'Thema', fieldName: 'ThemaIdOut', sortable: true, type: 'url', initialWidth: 500, typeAttributes: {label: {fieldName: 'ThemaOut'}, tooltip: {fieldName: 'TooltipOut'}, target: '_self'} }, {label: 'Kontakt', fieldName: 'KontaktIdOut', sortable: true, type: 'url', typeAttributes: {label: {fieldName: 'KontaktOut' }, target: '_self'} }, {label: 'Bezug zu', fieldName: 'BezugIdOut', sortable: true, type: 'url', typeAttributes: {label: {fieldName: 'BezugOut' }, target: '_self'} }, {label: 'Zugewiesen zu', fieldName: 'ZugewiesenOut', sortable: true, type: 'text' }, ]); }, 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); }, previous : function(component, event, helper){ component.set("v.isLastPage",false); var sObjectList = component.get("v.accountList"); console.log('sObjectList///',sObjectList); var startValue=component.get("v.startValue"); var endValue=component.get("v.endValue"); var perPage = component.get("v.perPageSize"); console.log('startValue///',startValue); console.log('endValue///',endValue); var totalRecords = component.get("v.totalRecords"); var values=[]; for(var i=startValue-perPage;i<startValue;i++){ console.log('i'+i); values.push(sObjectList[i]); } component.set("v.PaginationList",values); component.set("v.startValue",startValue-perPage); component.set("v.endValue",startValue-1); console.log('start value////'+component.get("v.startValue")); console.log('end value////'+component.get("v.endValue")); }, next : function(component, event, helper){ var sObjectList = component.get("v.accountList"); console.log('sObjectList///',sObjectList); var startValue=component.get("v.startValue"); var endValue=component.get("v.endValue"); var perPage = component.get("v.perPageSize"); console.log('startValue///',startValue); console.log('endValue///',endValue); var totalRecords = component.get("v.totalRecords"); var values=[]; //for eg------------------------------------------------------------------------- // this is page 2 and there are 10 records // endValue is 4 //if total no. of records == 4+5+1 (i.e. 10) //Or if total no. of records > 10, then evaluate this part---------------------- if(totalRecords >= endValue+perPage+1){ for(var i=endValue+1;i<endValue+perPage+1;i++){ values.push(sObjectList[i]); } if(totalRecords == endValue+perPage+1){//if total records == 4+5+1----------- component.set("v.isLastPage",true); } }//------------------------------------------------------------------------------ else{//if total number of records are lesser than 4+5+1(10) i.e. 8 for(var i=endValue+1;i<totalRecords;i++){ values.push(sObjectList[i]); } component.set("v.isLastPage",true); }//------------------------------------------------------------------------------ component.set("v.PaginationList",values); component.set("v.startValue",endValue+1); component.set("v.endValue",endValue+perPage); console.log('start value////'+component.get("v.startValue")); console.log('end value////'+component.get("v.endValue")); }, })
({ sortData: function (cmp, fieldName, sortDirection) { var fname = fieldName; var data = cmp.get("v.accountList"); var reverse = sortDirection !== 'asc'; data.sort(this.sortBy(fieldName, reverse)) cmp.set("v.accountList", 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)); } }, })
- Jonathan Wolff 7
- January 04, 2023
- Like
- 0
Sort Component descending by Date
Hello, I have an activity wrapper List component that shows different activities in one List with pagination. I already tried some code on the internet but I always got errors. Could you help me sort the Data by 'DatumOut', which is the date of the activity that is also shown in the component?
<aura:component controller="ApexActivityWrapper" implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" access="global"> <aura:attribute name="accountList" type="Object" /> <aura:attribute name="PaginationList" type="Object"/> <aura:attribute name="perPageSize" type="Integer" default="10"/> <aura:attribute name="totalRecords" type="Integer"/> <aura:attribute name="startValue" type="Integer" /> <aura:attribute name="endValue" type="Integer"/> <aura:attribute name="columns" type="List"/> <aura:attribute name="sortBy" type="String"/> <aura:attribute name="sortDirection" type="String"/> <aura:attribute name="isLastPage" type="Boolean"/> <aura:handler name="init" action="{!c.doInit}" value="{!this}"/> <!-- Ergebnisse + Pagination--> <div class="slds-grid slds-grid_vertical"> <aura:if isTrue="{!not(empty(v.PaginationList))}"> <lightning:datatable data="{!v.PaginationList}" columns="{!v.columns}" keyField="Id" sortedBy="{!v.sortBy}" hideCheckboxColumn="true" /> <aura:set attribute="else"> <div Style="text-align : center"> Keine Aktivitäten </div> </aura:set> </aura:if> <lightning:buttongroup> <lightning:button onclick="{!c.previous}" disabled="{!v.startValue == 0}" label="Previous" iconName='utility:back'/> <lightning:button onclick="{!c.next}" disabled="{!v.isLastPage}" label="Next" iconName='utility:forward'/> </lightning:buttongroup> </div> </aura:component>
({ doInit : function(component, event, helper) { 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(); component.set('v.accountList', response.getReturnValue()); console.log(component.get('v.accountList')); //total number of accounts recieved----------------------------------------- var lengthVar = component.get("v.accountList").length; console.log('length///'+lengthVar); component.set("v.totalRecords",lengthVar); //--------------------------------------------------------------------------- //number of records in each page--------------------------------------------- var perPage = component.get("v.perPageSize"); //--------------------------------------------------------------------------- var values=[]; console.log('perPage///'+perPage); //If total number of records are more than 5 or equals 5----------------------- if(lengthVar >= perPage){ for(var i=0;i<perPage;i++){ values.push(response.getReturnValue()[i]); } }//-------------------------------------------------------------------------- else{//If total number of records are lesser than 5-------------------------- for(var i=0;i<lengthVar;i++){ values.push(response.getReturnValue()[i]); } }//-------------------------------------------------------------------------- console.log('values///'+values); component.set("v.PaginationList",values); component.set("v.startValue",0); //if there are only 5 records or lesser than that in total------------------- if(lengthVar <= (component.get("v.startValue")+perPage)){ component.set("v.isLastPage",true); } component.set("v.endValue",component.get("v.startValue")+perPage-1); }); $A.enqueueAction(action); component.set('v.columns', [ {label: 'Status', fieldName: '', initialWidth: 50, cellAttributes: {iconName: {fieldName: 'StatusPicOut' } } }, //{label: "Datum", fieldName: 'DatumOut', sortable: true, type: "date", initialWidth: 80, typeAttributes: {month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", hour12: true } }, {label: "Datum", fieldName: 'DatumOut', sortable: true, type: "date", initialWidth: 110, typeAttributes: {day: '2-digit', month: '2-digit', year: '2-digit', hour: '2-digit', minute: '2-digit', hour12: false } }, {label: 'Art', fieldName: '', initialWidth: 60, cellAttributes: {iconName: {fieldName: 'ArtPicOut' } } }, {label: 'Thema', fieldName: 'ThemaIdOut', sortable: true, type: 'url', initialWidth: 500, typeAttributes: {label: {fieldName: 'ThemaOut'}, tooltip: {fieldName: 'TooltipOut'}, target: '_self'} }, {label: 'Kontakt', fieldName: 'KontaktIdOut', sortable: true, type: 'url', typeAttributes: {label: {fieldName: 'KontaktOut' }, target: '_self'} }, {label: 'Bezug zu', fieldName: 'BezugIdOut', sortable: true, type: 'url', typeAttributes: {label: {fieldName: 'BezugOut' }, target: '_self'} }, {label: 'Zugewiesen zu', fieldName: 'ZugewiesenOut', sortable: true, type: 'text' }, ]); }, previous : function(component, event, helper){ component.set("v.isLastPage",false); var sObjectList = component.get("v.accountList"); console.log('sObjectList///',sObjectList); var startValue=component.get("v.startValue"); var endValue=component.get("v.endValue"); var perPage = component.get("v.perPageSize"); console.log('startValue///',startValue); console.log('endValue///',endValue); var totalRecords = component.get("v.totalRecords"); var values=[]; for(var i=startValue-perPage;i<startValue;i++){ console.log('i'+i); values.push(sObjectList[i]); } component.set("v.PaginationList",values); component.set("v.startValue",startValue-perPage); component.set("v.endValue",startValue-1); console.log('start value////'+component.get("v.startValue")); console.log('end value////'+component.get("v.endValue")); }, next : function(component, event, helper){ var sObjectList = component.get("v.accountList"); console.log('sObjectList///',sObjectList); var startValue=component.get("v.startValue"); var endValue=component.get("v.endValue"); var perPage = component.get("v.perPageSize"); console.log('startValue///',startValue); console.log('endValue///',endValue); var totalRecords = component.get("v.totalRecords"); var values=[]; //for eg------------------------------------------------------------------------- // this is page 2 and there are 10 records // endValue is 4 //if total no. of records == 4+5+1 (i.e. 10) //Or if total no. of records > 10, then evaluate this part---------------------- if(totalRecords >= endValue+perPage+1){ for(var i=endValue+1;i<endValue+perPage+1;i++){ values.push(sObjectList[i]); } if(totalRecords == endValue+perPage+1){//if total records == 4+5+1----------- component.set("v.isLastPage",true); } }//------------------------------------------------------------------------------ else{//if total number of records are lesser than 4+5+1(10) i.e. 8 for(var i=endValue+1;i<totalRecords;i++){ values.push(sObjectList[i]); } component.set("v.isLastPage",true); }//------------------------------------------------------------------------------ component.set("v.PaginationList",values); component.set("v.startValue",endValue+1); component.set("v.endValue",endValue+perPage); console.log('start value////'+component.get("v.startValue")); console.log('end value////'+component.get("v.endValue")); }, })
public Class ApexActivityWrapper { // https://techdicer.com/how-to-created-lightning-datatable-with-sorting-of-columns/ @auraEnabled public static List<eEventTTask> ApexActivityWrapper (Id recordId) { // id recordId = '0010Q00001dBavUQAS'; system.debug('recordId =' + recordId); String sObjName = recordId.getSObjectType().getDescribe().getName(); /* in der Variablen sObjName wird der Name des aktuellen Objekts gespeichert */ system.debug('Objekt --> ' +sObjName); String FROMQuery = 'FROM '; List<eEventTTask> taskEventList = new List<eEventTTask>(); //########################################################################## //########################### CONTACT START ################################ //########################################################################## // Komponente auf Kontakt eingefügt, dann wird das folgende ausgeführt if(sObjName == 'Contact') { List<Contact> recordName = [SELECT Name FROM Contact WHERE Id = :recordId LIMIT 1]; system.debug('ContactName -->' + recordName + ' ' + recordName[0].name); // Abfrage von Terminen/Events for (Event e: [SELECT Id, Subject, ActivityDate, ActivityDatetime, What.Name, What.Id, Owner.Name, Who.Name, Who.Id FROM Event WHERE Id IN (SELECT EventId FROM EventRelation WHERE RelationId = :recordId)]) { taskEventList.add(new eEventTTask(e.Subject, e.ActivityDatetime, 'E', e.What.Name, e.Owner.Name, e.Id, e.What.Id, 'standard:event', '', e.Who.Name, e.Who.Id, e.Subject)); } // Abfrage von Aufgaben/Tasks bis 31.07.2022 - danach wurde das neue Addin akiviert und somit werden leider für jede email die abgelegt wird eine EmailMessage und Task angelegt for (Task t: [SELECT Id, Subject, CreatedDate, ActivityDate, What.Name, What.Id, Owner.Name, Status, Who.Name, Who.Id, Description FROM Task WHERE (Activitydate <= 2022-08-27 OR Activitydate = null) AND Id IN (SELECT TaskId FROM TaskRelation WHERE RelationId = :recordId)]) { //taskEventList.add(new eEventTTask(t.Subject, datetime.newInstance(t.ActivityDate.year(), t.ActivityDate.month(), t.ActivityDate.day(), 0, 0, 0), 'T', t.What.Name, t.Owner.Name, t.Id, t.What.Id, 'standard:task', t.Status, t.Who.Name, t.Who.Id)); taskEventList.add(new eEventTTask(t.Subject, t.CreatedDate, 'T', t.What.Name, t.Owner.Name, t.Id, t.What.Id, 'standard:task', t.Status, t.Who.Name, t.Who.Id, t.Description)); } // Abfrage von Aufgaben/Tasks ab 01.08.2022 - danach wurde das neue Addin akiviert und somit werden leider für jede email die abgelegt wird eine EmailMessage und Task angelegt for (Task t: [SELECT Id, Subject, CreatedDate, ActivityDate, What.Name, What.Id, Owner.Name, Status, Who.Name, Who.Id, Description FROM Task WHERE Activitydate > 2022-08-27 AND TaskSubType != 'Email' AND Id IN (SELECT TaskId FROM TaskRelation WHERE RelationId = :recordId)]) { //taskEventList.add(new eEventTTask(t.Subject, datetime.newInstance(t.ActivityDate.year(), t.ActivityDate.month(), t.ActivityDate.day(), 0, 0, 0), 'T', t.What.Name, t.Owner.Name, t.Id, t.What.Id, 'standard:task', t.Status, t.Who.Name, t.Who.Id)); taskEventList.add(new eEventTTask(t.Subject, t.CreatedDate, 'T', t.What.Name, t.Owner.Name, t.Id, t.What.Id, 'standard:task', t.Status, t.Who.Name, t.Who.Id, t.Description)); } // Abfrage von Email-Messages for (EmailMessage m: [SELECT Id, Subject, MessageDate, RelatedToId, RelatedTo.Name, CreatedBy.Name, HtmlBody FROM EmailMessage WHERE Id IN (SELECT EmailMessageId from EmailMessageRelation WHERE RelationId = :recordId)]) { taskEventList.add(new eEventTTask(m.Subject, datetime.newInstance(m.MessageDate.year(), m.MessageDate.month(), m.MessageDate.day(), m.MessageDate.hour(), m.MessageDate.minute(), 0), 'M', m.RelatedTo.Name, m.CreatedBy.Name, m.Id, m.RelatedToId, 'standard:email', '', recordName[0].name, recordId, m.HtmlBody)); } // 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, datetime.newInstance(n.CreatedDate.year(), n.CreatedDate.month(), n.CreatedDate.day(), 0, 0, 0), 'N', n.Parent.Name, n.Owner.Name, n.Id, n.ParentId, 'standard:note', '', recordName[0].name, recordId)); taskEventList.add(new eEventTTask(n.Title, n.CreatedDate, 'N', n.Parent.Name, n.Owner.Name, n.Id, n.ParentId, 'standard:note', '', recordName[0].name, recordId, n.title)); } // 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, datetime.newInstance(a.CreatedDate.year(), a.CreatedDate.month(), a.CreatedDate.day(), 0, 0, 0), 'A', a.Parent.Name, a.Owner.Name, a.Id, a.ParentId, 'standard:note', '', recordName[0].name, recordId)); taskEventList.add(new eEventTTask(a.Name, a.CreatedDate, 'A', a.Parent.Name, a.Owner.Name, a.Id, a.ParentId, 'standard:note', '', recordName[0].name, recordId, a.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, datetime.newInstance(c.ContentDocument.CreatedDate.year(), c.ContentDocument.CreatedDate.month(), c.ContentDocument.CreatedDate.day(), 0 , 0, 0), 'C', c.LinkedEntity.Name, c.ContentDocument.CreatedBy.Name, c.ContentDocumentId, c.LinkedEntity.Id, 'utility:file', '', recordName[0].name, recordId)); taskEventList.add(new eEventTTask(c.ContentDocument.Title, c.ContentDocument.CreatedDate, 'C', c.LinkedEntity.Name, c.ContentDocument.CreatedBy.Name, c.ContentDocumentId, c.LinkedEntity.Id, 'standard:file', '', recordName[0].name, recordId, c.ContentDocument.Title)); } // Abfrage von Wiedervorlagen // for(Wiedervorlage__c w: [SELECT Id, Beschreibung__c, Erinnerungstermin__c, Wiedervorlage_f_r__c, Wiedervorlage_f_r_Name__c, Wiedervorlage_f_r_Id__c, Owner.Name FROM Wiedervorlage__c WHERE Wiedervorlage_f_r_Id__c = :recordId]) { // taskEventList.add(new eEventTTask(w.Beschreibung__c, w.Erinnerungstermin__c, 'W', w.Wiedervorlage_f_r_Name__c, w.Owner.Name, w.Id, '', 'standard:today', '', recordName[0].name, w.Wiedervorlage_f_r_Id__c, w.Beschreibung__c)); // } } //########################### CONTACT ENDE ################################# //########################################################################## //########################### ACCOUNT START ################################ //########################################################################## // Komponente auf Kontakt eingefügt, dann wird das folgende ausgeführt if(sObjName == 'Account') { // Abfrage von Aufgaben/Tasks bis 31.07.2022 - danach wurde das neue Addin akiviert und somit werden leider für jede email die abgelegt wird eine EmailMessage und Task angelegt //for (Task t: [SELECT Id, Subject, ActivityDate, What.Name, What.Id, Owner.Name, Status, Who.Name, Who.Id FROM Task WHERE Activitydate <= 2022-08-26 AND Id IN (SELECT TaskId FROM TaskRelation WHERE RelationId = :recordId)]) { for (Task t: [SELECT Id, Subject, ActivityDate, CreatedDate, Createdby.Name, Owner.Name, RecordType.Name, Status, Who.Name, Who.Id, What.Name, Description from Task WHERE AccountId = :recordId AND WhoId = '' AND (Activitydate <= 2022-08-27 OR Activitydate = null)]) { taskEventList.add(new eEventTTask(t.Subject, t.CreatedDate, 'T', t.What.Name, t.Owner.Name, t.Id, t.What.Id, 'standard:task', t.Status, t.Who.Name, t.Who.Id, t.Description)); } // Abfrage von Aufgaben/Tasks ab 01.08.2022 - danach wurde das neue Addin akiviert und somit werden leider für jede email die abgelegt wird eine EmailMessage und Task angelegt //for (Task t: [SELECT Id, Subject, ActivityDate, What.Name, What.Id, Owner.Name, Status, Who.Name, Who.Id FROM Task WHERE Activitydate > 2022-08-26 AND TaskSubType != 'Email' AND Id IN (SELECT TaskId FROM TaskRelation WHERE RelationId = :recordId)]) { for (Task t: [SELECT Id, Subject, ActivityDate, CreatedDate, Createdby.Name, Owner.Name, RecordType.Name, Status, Who.Name, Who.Id, What.Name, Description from Task WHERE AccountId = :recordId AND WhoId = '' AND Activitydate > 2022-08-27 AND TaskSubType != 'Email']) { taskEventList.add(new eEventTTask(t.Subject, t.CreatedDate, 'T', t.What.Name, t.Owner.Name, t.Id, t.What.Id, 'standard:task', t.Status, t.Who.Name, t.Who.Id, t.Description)); } // Abfrage von Aufgaben/Tasks - in dieser Abfrage werden alle Aufgaben von AG-Kontakten selektiert die diesem Unternehmen zugeordnet sind Map<Id, TaskWhoRelation> relatedTasksAcc = new Map<Id, TaskWhoRelation>([SELECT taskId FROM TaskWhoRelation WHERE AccountId = :recordId AND RelationId IN (SELECT Id FROM Contact WHERE RecordTypeId = '012b0000000UNQxAAO')]); Set<Id> taskidsset = new Set<Id>(); for(taskwhorelation relation:relatedTasksAcc.values()) { taskidsset.add(relation.taskid); } system.debug('size relatedtasksAcc ' +relatedtasksAcc.size()); system.debug('size taskidsset ' +taskidsset.size()); List<Task> listtask1 = [SELECT Id, Subject, CreatedDate, ActivityDate, What.Name, What.Id, Owner.Name, Status, Who.Name, Who.Id, Description FROM Task WHERE (Activitydate <= 2022-08-27 OR Activitydate = null) AND Id IN :taskidsset]; system.debug('size listtask1 ' +listtask1.size()); for(Task t : listtask1) { taskEventList.add(new eEventTTask(t.Subject, t.CreatedDate, 'T', t.What.Name, t.Owner.Name, t.Id, t.What.Id, 'standard:task', t.Status, t.Who.Name, t.Who.Id, t.Description)); } List<Task> listtask2 = [SELECT Id, Subject, CreatedDate, ActivityDate, What.Name, What.Id, Owner.Name, Status, Who.Name, Who.Id, Description FROM Task WHERE Activitydate > 2022-08-27 AND TaskSubType != 'Email' AND Id IN :taskidsset]; system.debug('size listtask2 ' +listtask2.size()); for(Task t : listtask2) { taskEventList.add(new eEventTTask(t.Subject, t.CreatedDate, 'T', t.What.Name, t.Owner.Name, t.Id, t.What.Id, 'standard:task', t.Status, t.Who.Name, t.Who.Id, t.Description)); } // Abfrage von Termine/Events - in dieser Abfrage werden alle Termine von AG-Kontakten selektiert die diesem Unternehmen zugeordnet sind Map<Id, EventWhoRelation> relatedEventAcc = new Map<Id, EventWhoRelation>([SELECT EventId FROM EventWhoRelation WHERE AccountId = :recordId and RelationId IN (SELECT Id FROM Contact WHERE RecordTypeId = '012b0000000UNQxAAO')]); Set<Id> eventidsset = new Set<Id>(); for(eventwhorelation relation:relatedEventAcc.values()){ eventidsset.add(relation.eventid); } system.debug('size relatedeventAcc ' +relatedeventAcc.size()); system.debug('size eventidsset ' +eventidsset.size()); List<Event> listevent = [SELECT Id, Subject, ActivityDate, ActivityDatetime, What.Name, What.Id, Owner.Name, Who.Name, Who.Id FROM Event WHERE Id IN :eventidsset]; system.debug('size listevent ' +listevent.size()); for(event e : listevent) { taskEventList.add(new eEventTTask(e.Subject, e.ActivityDatetime, 'E', e.What.Name, e.Owner.Name, e.Id, e.What.Id, 'standard:event', '', e.Who.Name, e.Who.Id, e.Subject)); } // 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, c.ContentDocument.CreatedDate, 'C', c.LinkedEntity.Name, c.ContentDocument.CreatedBy.Name, c.ContentDocumentId, c.LinkedEntity.Id, 'standard:file', '', '', '', c.ContentDocument.Title)); } for(ContentDocumentLink c: [SELECT Id, ContentDocumentId, ContentDocument.Title, ContentDocument.createdDate, ContentDocument.Createdby.Name, ContentDocument.FileExtension, LinkedEntity.Id, LinkedEntity.Name FROM ContentDocumentLink WHERE LinkedEntityId IN (SELECT Id FROM Contact WHERE AccountId =: recordId)]) { taskEventList.add(new eEventTTask(c.ContentDocument.Title, c.ContentDocument.CreatedDate, 'C', c.LinkedEntity.Name, c.ContentDocument.CreatedBy.Name, c.ContentDocumentId, c.LinkedEntity.Id, 'standard:file', '', '', '', c.ContentDocument.Title)); } // 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, a.CreatedDate, 'A', a.Parent.Name, a.Owner.Name, a.Id, a.ParentId, 'standard:note', '', '', '', a.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 IN (SELECT Id FROM Contact WHERE AccountId =: recordId and RecordTypeId = '012b0000000UNQxAAO')]) { taskEventList.add(new eEventTTask(a.Name, a.CreatedDate, 'A', a.Parent.Name, a.Owner.Name, a.Id, a.ParentId, 'standard:note', '', '', '', a.Name)); } // 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, n.CreatedDate, 'N', n.Parent.Name, n.Owner.Name, n.Id, n.ParentId, 'standard:note', '', '', '', n.Title)); } // Abfrage von Notizen/Notes for(Note n: [SELECT Id, Title, CreatedDate, Createdby.Name, Owner.Name, Parent.Name, ParentId FROM Note WHERE ParentId IN (SELECT Id FROM Contact WHERE AccountId = :recordId AND RecordTypeId = '012b0000000UNQxAAO')]) { taskEventList.add(new eEventTTask(n.Title, n.CreatedDate, 'N', n.Parent.Name, n.Owner.Name, n.Id, n.ParentId, 'standard:note', '', '', '', n.Title)); } // Abfrage von Email-Messages for (EmailMessage m: [SELECT Id, Subject, MessageDate, RelatedToId, RelatedTo.Name, CreatedBy.Name, HtmlBody FROM EmailMessage WHERE RelatedToId = :recordId]) { taskEventList.add(new eEventTTask(m.Subject, m.MessageDate, 'M', m.RelatedTo.Name, m.CreatedBy.Name, m.Id, m.RelatedToId, 'standard:email', '', '', '', m.HtmlBody)); } // Abfrage von Email-Messages for (EmailMessageRelation m: [SELECT Id, EmailMessageId, EmailMessage.Subject, EmailMessage.MessageDate, EmailMessage.RelatedToId, EmailMessage.RelatedTo.Name, EmailMessage.CreatedBy.Name, Relation.Name, EmailMessage.HtmlBody FROM EmailMessageRelation WHERE RelationId IN (SELECT Id FROM Contact WHERE AccountId = :recordId AND RecordTypeId = '012b0000000UNQxAAO')]) { taskEventList.add(new eEventTTask(m.EmailMessage.Subject, m.EmailMessage.MessageDate, 'M', m.EmailMessage.RelatedTo.Name, m.EmailMessage.CreatedBy.Name, m.EmailMessage.Id, m.EmailMessage.RelatedToId, 'standard:email', '', m.Relation.Name, m.RelationId, m.EmailMessage.HtmlBody)); system.debug('Name --> ' + m.Relation.Name); } // Abfrage von Wiedervorlagen // for(Wiedervorlage__c w: [SELECT Id, Beschreibung__c, Erinnerungstermin__c, Wiedervorlage_f_r__c, Wiedervorlage_f_r_Name__c, Wiedervorlage_f_r_Id__c, Owner.Name FROM Wiedervorlage__c WHERE Wiedervorlage_f_r_Id__c = :recordId]) { // taskEventList.add(new eEventTTask(w.Beschreibung__c, w.Erinnerungstermin__c, 'W', w.Wiedervorlage_f_r_Name__c, w.Owner.Name, w.Id, '', 'standard:today', '', w.Wiedervorlage_f_r_Name__c, w.Wiedervorlage_f_r_Id__c, w.Beschreibung__c)); // } } //########################### ACCOUNT ENDE ################################## system.debug('taskEventList' + taskEventList); return taskEventList; } public class eEventTTask { @AuraEnabled public String ThemaOut {get; set;} @AuraEnabled public Datetime DatumOut {get; set;} @AuraEnabled public String ArtOut {get; set;} @AuraEnabled public String BezugOut {get; set;} @AuraEnabled public String ZugewiesenOut {get; set;} @AuraEnabled public String ThemaIdOut {get; set;} @AuraEnabled public String BezugIdOut {get; set;} @AuraEnabled public String ArtPicOut {get; set;} @AuraEnabled public String StatusPicOut {get; set;} @AuraEnabled public String KontaktOut {get; set;} @AuraEnabled public String KontaktIdOut {get; set;} @AuraEnabled public String TooltipOut {get; set;} public eEventTTask(String ThemaIn, Datetime DatumIn, String ArtIn, String BezugIn, String ZugewiesenIn, String ThemaIdIn, String BezugIdIn, String ArtPicIn, String StatusIn, String KontaktIn, String KontaktIdIn, String TooltipIn) { ThemaOut = ThemaIn; DatumOut = DatumIn; ArtOut = ArtIn; BezugOut = BezugIn; ZugewiesenOut = ZugewiesenIn; IF(ThemaIdIn != Null) { ThemaIdOut = '/' + ThemaIdIn; } IF(BezugIdIn != Null) { BezugIdOut = '/' + BezugIdIn; } ArtPicOut = ArtPicIn; IF(ArtIn == 'm' || ArtIn == 'n' || ArtIn == 'c' || ArtIn == 'a' || (ArtIn == 'e' && DatumIn <= date.today()) || (ArtIn == 't' && (StatusIn == 'Completed' || StatusIn == 'Fertiggestellt'))) { StatusPicOut = 'custom:custom6'; } //grün ELSE IF ((ArtIn == 'e' && DatumIn > date.today()) || // (ArtIn == 'w' && DatumIn > date.today()) || (ArtIn == 't' && DatumIn > date.today() && StatusIn != 'Fertiggestellt' && StatusIn != 'Completed')) { StatusPicOut = 'custom:custom4'; } // gelb ELSE IF ((ArtIn == 't' && DatumIn <= date.today() && (StatusIn != 'Fertiggestellt' || StatusIn != 'Completed')) || (ArtIn == 'w' && DatumIn <= date.today())) { StatusPicOut = 'custom:custom49'; } // rot KontaktOut = KontaktIn; IF(KontaktIdIn != '' && KontaktIdIn != Null) { KontaktIdOut = '/' + KontaktIdIn; } TooltipOut = TooltipIn; } } }
- Jonathan Wolff 7
- December 21, 2022
- Like
- 0
Align lightning:select label to the left
Hello,
i would like to align my lightning:select label to the left. Right now it is like that:
I want the labels 'Typ2', 'Thema' and 'Zielgruppe to be aligned on the left (beginning of the select). Is there a possibility to achive this?
Greetings
Jonathan
i would like to align my lightning:select label to the left. Right now it is like that:
I want the labels 'Typ2', 'Thema' and 'Zielgruppe to be aligned on the left (beginning of the select). Is there a possibility to achive this?
Greetings
Jonathan
- Jonathan Wolff 7
- December 16, 2022
- Like
- 0
Add reset button to search aura component
Hello, i have a component that searches inputs in a custom object. I want a button method that resets the component, so that it empties the search bar and hides the results of the previous search. Could you help me with the implementation
Controller
Helper
<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}"/> <!-- <aura:handler name="change" value="{!v.searchKey}" action="{!c.valueChangeValidation}"/> --> <!-- attributes --> <aura:attribute name="showSearchResults" type="Boolean" default="false"/> <aura:attribute name="searchKey" type="String" default=""/> <aura:attribute name="mediathekList" type="List" default="Mediathek[]"/> <aura:attribute name="mediathekColumns" type="List"/> <aura:attribute name="TypValue" type="String" default="Alle"/> <aura:attribute name="ZielgruppeValue" type="String" default="Alle"/> <aura:attribute name="ThemaValue" type="String" default="Alle"/> <aura:attribute name="tooltip" type="boolean" default="false" /> <div class= "slds-box slds-p-top_none slds-p-bottom_none slds-p-right_none"> <div class="slds-grid slds-wrap" > <div class="slds-size_12-of-12 "> <lightning:layout multipleRows="true"> <lightning:layoutItem size="7"> <lightning:input aura:id="inputField" name="searchKey" placeholder="Bitte geben Sie mindestens 2 Buchstaben ein, um zu suchen" value="{!v.searchKey}" onkeyup="{!c.search}" messageWhenBadInput="Es müssen mindestens 2 Zeichen eingegeben werden"/> </lightning:layoutItem> <lightning:layoutItem size="1"/> <lightning:layoutItem size="1"> <lightning:button variant="brand" label="Suchen" title="Search" onclick="{!c.search}" class="customButton" /> </lightning:layoutItem> <lightning:layoutItem size="3"/> <lightning:layoutItem size="3"> <lightning:select aura:id="TypValue" name="Typ" label="Typ" required="false" value="{!v.TypValue}"> <option value="Alle">Alle</option> <option value="Formular">Formular</option> <option value="Merkblatt">Merkblatt</option> <option value="Flyer">Flyer</option> <option value="Infobroschüre">Infobroschüre</option> </lightning:select> </lightning:layoutItem> <lightning:layoutItem size="1"/> <lightning:layoutItem size="3"> <lightning:select aura:id="ThemaValue" name="Thema" label="Thema" required="false" value="{!v.ThemaValue}"> <option value="Alle">Alle</option> <option value="Altersvorsorge">Altersvorsorge</option> <option value="AOK">AOK</option> <option value="Beratungstag">Beratungstag</option> <option value="Berufsunfähigkeit">Berufsunfähigkeit</option> <option value="Berufsunfähigkeit privat">Berufsunfähigkeit privat</option> <option value="bKV">bKV</option> <option value="BRSG">BRSG</option> <option value="Direktversicherung">Direktversicherung</option> <option value="Direktversicherung, ergänzende Berufsunfähigkeit, Berufsunfähigkeit">Direktversicherung, ergänzende Berufsunfähigkeit, Berufsunfähigkeit</option> <option value="Direktversicherung, Pensionsfonds">Direktversicherung, Pensionsfonds</option> <option value="Direktversicherung, Pensionskasse">Direktversicherung, Pensionskasse</option> <option value="Direktversicherung, Pensionskasse, Pensionsfonds">Direktversicherung, Pensionskasse, Pensionsfonds</option> <option value="englisches Material">englisches Material</option> <option value="FID FIR">FID FIR</option> <option value="Firmenversicherung (Gruppenvertrag)">Firmenversicherung (Gruppenvertrag)</option> <option value="Kundencall">Kundencall</option> <option value="Lebensversicherung privat">Lebensversicherung privat</option> <option value="Pensionsfonds">Pensionsfonds</option> <option value="Pensionskasse">Pensionskasse</option> <option value="Pensionszusage">Pensionszusage</option> <option value="privat">privat</option> <option value="PrivatRente, Schatzbrief Perspektive">PrivatRente, Schatzbrief Perspektive</option> <option value="Produktinfo">Produktinfo</option> <option value="rechtliche Unterlage">rechtliche Unterlage</option> <option value="Riester">Riester</option> <option value="Rückdeckungsversicherung FIR">Rückdeckungsversicherung FIR</option> <option value="Unterstützungskasse">Unterstützungskasse</option> <option value="Zeitwertkonto">Zeitwertkonto</option> <option value="Zusatzbausteine">Zusatzbausteine</option> </lightning:select> </lightning:layoutItem> <lightning:layoutItem size="1"/> <lightning:layoutItem size="3"> <lightning:select aura:id="ZielgruppeValue" name="Zielgruppe" label="Zielgruppe" required="false" value="{!v.ZielgruppeValue}"> <option value="Alle">Alle</option> <option value="Arbeitgeber">Arbeitgeber</option> <option value="Arbeitnehmer">Arbeitnehmer</option> <option value="Berater">Berater</option> <option value="Verband">Verband</option> <option value="Arbeitgeber/Arbeitnehmer">Arbeitgeber/Arbeitnehmer</option> <option value="Azubi">Azubi</option> <option value="IGM">IGM</option> </lightning:select> </lightning:layoutItem> </lightning:layout> </div> </div> <div class="haha" style="margin-right:300px"> <aura:if isTrue="{!v.showSearchResults}"> <!-- <lightning:layout multipleRows="true"> <lightning:layoutItem padding="around-large" size="12" > <lightning:datatable keyField="id" data="{!v.mediathekList}" columns="{!v.mediathekColumns}" hideCheckboxColumn="true"/> </lightning:layoutItem> </lightning:layout> --> <table class="slds-table slds-table--bordered slds-table--striped slds-p-right_medium"> <thead> <tr> <th scope="col"><span class="slds-truncate">Bezeichnung</span></th> <th scope="col"><span class="slds-truncate">Typ</span></th> <th scope="col"><span class="slds-truncate">Zielgruppe</span></th> <th scope="col"><span class="slds-truncate">Umfang</span></th> <th scope="col"><span class="slds-truncate">CVID</span></th> <!-- <th scope="col"><span class="slds-truncate">Vorschau</span></th> --> </tr> </thead> <tbody> <aura:iteration items="{!v.mediathekList}" var="media"> <tr height="300px"> <td style="background-color:#F8F8F8; width:200px">{!media.Bezeichnung__c}</td> <td style="background-color:#F8F8F8">{!media.Typ__c}</td> <td style="background-color:#F8F8F8">{!media.Zielgruppe__c}</td> <td style="background-color:#F8F8F8">{!media.Umfang__c}</td> <td style="background-color:#F8F8F8"><img src="{!'/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId=' + media.ContentVersionId__c}" alt="Keine Vorschau verfügbar"/></td> <!-- <td style="background-color:#F8F8F8"> <lightning:fileCard fileId="{!media.ContentDocumentID__c}" description="{!media.Bezeichnung__c}"/> </td> --> </tr> </aura:iteration> </tbody> </table> </aura:if> </div> </div> </aura:component>
Controller
({ 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, }, {label: 'Preview', fieldName: 'Bild_Preview__c', type: 'image', fixedWidth: 300, }, ]); */ 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); } }) ({ 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: 'Thema', fieldName: 'Thema__c', type: 'text', fixedWidth: 112, }, {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({ TypValue : component.get("v.TypValue"), searchKey : component.get("v.searchKey"), ZielgruppeValue : component.get("v.ZielgruppeValue"), ThemaValue : component.get("v.ThemaValue") }); // 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); } })
- Jonathan Wolff 7
- December 05, 2022
- Like
- 0
Open lightning:filecard when clicking over button in table
Hello,
I use a html table that includes a button. I would like to show lightning:filecard when the button is pressed. Could you tell me how I can achive that?
I use a html table that includes a button. I would like to show lightning:filecard when the button is pressed. Could you tell me how I can achive that?
<table class="slds-table slds-table--bordered slds-table--striped"> <thead> <tr> <th scope="col"><span class="slds-truncate">Bezeichnung</span></th> <th scope="col"><span class="slds-truncate">Thema</span></th> <th scope="col"><span class="slds-truncate">Typ</span></th> <th scope="col"><span class="slds-truncate">Zielgruppe</span></th> <th scope="col"><span class="slds-truncate">Umfang</span></th> <th scope="col"><span class="slds-truncate">Vorschau</span></th> </tr> </thead> <tbody> <aura:iteration items="{!v.mediathekList}" var="media"> <tr height="300px"> <td style="background-color:#F8F8F8; ">{!media.Bezeichnung__c}</td> <td style="background-color:#F8F8F8">{!media.Thema__c}</td> <td style="background-color:#F8F8F8">{!media.Typ__c}</td> <td style="background-color:#F8F8F8">{!media.Zielgruppe__c}</td> <td style="background-color:#F8F8F8">{!media.Umfang__c}</td> <td style="background-color:#F8F8F8"> <button type="button" title="" id="Vorschau">Vorschau</button></td> <!-- <td style="background-color:#F8F8F8"> <lightning:fileCard fileId="{!media.ContentDocumentID__c}" description="{!media.Bezeichnung__c}"/> </td> --> </tr> </aura:iteration> </tbody> </table>
- Jonathan Wolff 7
- November 30, 2022
- Like
- 0
Populate Version Id through trigger
Hello, I have a trigger that populates the ContentDocumentId into a field. Now i would to like to populate the version Id too, but i dont know how to get it into the field VersionId__c
trigger ContentIdEintragen on ContentDocumentLink (after insert, before update) { map<id,id> parentids = new map<id,id>(); for(ContentDocumentLink cdl:trigger.new){ parentids.put(cdl.LinkedEntityId,cdl.ContentDocumentId); } List<Mediathek__c> ContentDocumentIdupdate = new List<Mediathek__c>(); for(Mediathek__c mt:[select id from Mediathek__c where id IN:parentids.keyset()]){ if(parentids.containskey(mt.id)){ mt.ContentDocumentID__c = parentids.get(mt.id); mt.VersionId__c =... ; ContentDocumentIdupdate.add(mt); } } update ContentDocumentIdupdate; }
- Jonathan Wolff 7
- November 28, 2022
- Like
- 0
Change Apex Class of component
Hello, I am using a pagination component for accounts. I would like to change the apex class of the component to include different data. The problem is, that I am using a wrapper as new apex class and get errors when I implement it.
The new apex class which data i want to display is:
The code of my component how it is rn is the following:
The new apex class which data i want to display is:
public Class ApexActivityWrapper { // https://techdicer.com/how-to-created-lightning-datatable-with-sorting-of-columns/ @auraEnabled public static List<eEventTTask> ApexActivityWrapper (Id recordId) { system.debug('recordId =' + recordId); String sObjName = recordId.getSObjectType().getDescribe().getName(); /* in der Variablen sObjName wird der Name des aktuellen Objekts gespeichert */ system.debug('Objekt --> ' +sObjName); String FROMQuery = 'FROM '; List<eEventTTask> taskEventList = new List<eEventTTask>(); //########################################################################## //########################### CONTACT START ################################ //########################################################################## // Komponente auf Kontakt eingefügt, dann wird das folgende ausgeführt if(sObjName == 'Contact') { List<Contact> recordName = [SELECT Name FROM Contact WHERE Id = :recordId LIMIT 1]; system.debug('ContactName -->' + recordName + ' ' + recordName[0].name); // Abfrage von Terminen/Events for (Event e: [SELECT Id, Subject, ActivityDate, ActivityDatetime, What.Name, What.Id, Owner.Name, Who.Name, Who.Id FROM Event WHERE Id IN (SELECT EventId FROM EventRelation WHERE RelationId = :recordId)]) { taskEventList.add(new eEventTTask(e.Subject, e.ActivityDatetime, 'E', e.What.Name, e.Owner.Name, e.Id, e.What.Id, 'standard:event', '', e.Who.Name, e.Who.Id, e.Subject)); } // Abfrage von Aufgaben/Tasks bis 31.07.2022 - danach wurde das neue Addin akiviert und somit werden leider für jede email die abgelegt wird eine EmailMessage und Task angelegt for (Task t: [SELECT Id, Subject, CreatedDate, ActivityDate, What.Name, What.Id, Owner.Name, Status, Who.Name, Who.Id, Description FROM Task WHERE (Activitydate <= 2022-08-27 OR Activitydate = null) AND Id IN (SELECT TaskId FROM TaskRelation WHERE RelationId = :recordId)]) { //taskEventList.add(new eEventTTask(t.Subject, datetime.newInstance(t.ActivityDate.year(), t.ActivityDate.month(), t.ActivityDate.day(), 0, 0, 0), 'T', t.What.Name, t.Owner.Name, t.Id, t.What.Id, 'standard:task', t.Status, t.Who.Name, t.Who.Id)); taskEventList.add(new eEventTTask(t.Subject, t.CreatedDate, 'T', t.What.Name, t.Owner.Name, t.Id, t.What.Id, 'standard:task', t.Status, t.Who.Name, t.Who.Id, t.Description)); } // Abfrage von Aufgaben/Tasks ab 01.08.2022 - danach wurde das neue Addin akiviert und somit werden leider für jede email die abgelegt wird eine EmailMessage und Task angelegt for (Task t: [SELECT Id, Subject, CreatedDate, ActivityDate, What.Name, What.Id, Owner.Name, Status, Who.Name, Who.Id, Description FROM Task WHERE Activitydate > 2022-08-27 AND TaskSubType != 'Email' AND Id IN (SELECT TaskId FROM TaskRelation WHERE RelationId = :recordId)]) { //taskEventList.add(new eEventTTask(t.Subject, datetime.newInstance(t.ActivityDate.year(), t.ActivityDate.month(), t.ActivityDate.day(), 0, 0, 0), 'T', t.What.Name, t.Owner.Name, t.Id, t.What.Id, 'standard:task', t.Status, t.Who.Name, t.Who.Id)); taskEventList.add(new eEventTTask(t.Subject, t.CreatedDate, 'T', t.What.Name, t.Owner.Name, t.Id, t.What.Id, 'standard:task', t.Status, t.Who.Name, t.Who.Id, t.Description)); } // Abfrage von Email-Messages for (EmailMessage m: [SELECT Id, Subject, MessageDate, RelatedToId, RelatedTo.Name, CreatedBy.Name, HtmlBody FROM EmailMessage WHERE Id IN (SELECT EmailMessageId from EmailMessageRelation WHERE RelationId = :recordId)]) { taskEventList.add(new eEventTTask(m.Subject, datetime.newInstance(m.MessageDate.year(), m.MessageDate.month(), m.MessageDate.day(), m.MessageDate.hour(), m.MessageDate.minute(), 0), 'M', m.RelatedTo.Name, m.CreatedBy.Name, m.Id, m.RelatedToId, 'standard:email', '', recordName[0].name, recordId, m.HtmlBody)); } // 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, datetime.newInstance(n.CreatedDate.year(), n.CreatedDate.month(), n.CreatedDate.day(), 0, 0, 0), 'N', n.Parent.Name, n.Owner.Name, n.Id, n.ParentId, 'standard:note', '', recordName[0].name, recordId)); taskEventList.add(new eEventTTask(n.Title, n.CreatedDate, 'N', n.Parent.Name, n.Owner.Name, n.Id, n.ParentId, 'standard:note', '', recordName[0].name, recordId, n.title)); } // 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, datetime.newInstance(a.CreatedDate.year(), a.CreatedDate.month(), a.CreatedDate.day(), 0, 0, 0), 'A', a.Parent.Name, a.Owner.Name, a.Id, a.ParentId, 'standard:note', '', recordName[0].name, recordId)); taskEventList.add(new eEventTTask(a.Name, a.CreatedDate, 'A', a.Parent.Name, a.Owner.Name, a.Id, a.ParentId, 'standard:note', '', recordName[0].name, recordId, a.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, datetime.newInstance(c.ContentDocument.CreatedDate.year(), c.ContentDocument.CreatedDate.month(), c.ContentDocument.CreatedDate.day(), 0 , 0, 0), 'C', c.LinkedEntity.Name, c.ContentDocument.CreatedBy.Name, c.ContentDocumentId, c.LinkedEntity.Id, 'utility:file', '', recordName[0].name, recordId)); taskEventList.add(new eEventTTask(c.ContentDocument.Title, c.ContentDocument.CreatedDate, 'C', c.LinkedEntity.Name, c.ContentDocument.CreatedBy.Name, c.ContentDocumentId, c.LinkedEntity.Id, 'standard:file', '', recordName[0].name, recordId, c.ContentDocument.Title)); } // Abfrage von Wiedervorlagen // for(Wiedervorlage__c w: [SELECT Id, Beschreibung__c, Erinnerungstermin__c, Wiedervorlage_f_r__c, Wiedervorlage_f_r_Name__c, Wiedervorlage_f_r_Id__c, Owner.Name FROM Wiedervorlage__c WHERE Wiedervorlage_f_r_Id__c = :recordId]) { // taskEventList.add(new eEventTTask(w.Beschreibung__c, w.Erinnerungstermin__c, 'W', w.Wiedervorlage_f_r_Name__c, w.Owner.Name, w.Id, '', 'standard:today', '', recordName[0].name, w.Wiedervorlage_f_r_Id__c, w.Beschreibung__c)); // } } //########################### CONTACT ENDE ################################# //########################################################################## //########################### ACCOUNT START ################################ //########################################################################## // Komponente auf Kontakt eingefügt, dann wird das folgende ausgeführt if(sObjName == 'Account') { // Abfrage von Aufgaben/Tasks bis 31.07.2022 - danach wurde das neue Addin akiviert und somit werden leider für jede email die abgelegt wird eine EmailMessage und Task angelegt //for (Task t: [SELECT Id, Subject, ActivityDate, What.Name, What.Id, Owner.Name, Status, Who.Name, Who.Id FROM Task WHERE Activitydate <= 2022-08-26 AND Id IN (SELECT TaskId FROM TaskRelation WHERE RelationId = :recordId)]) { for (Task t: [SELECT Id, Subject, ActivityDate, CreatedDate, Createdby.Name, Owner.Name, RecordType.Name, Status, Who.Name, Who.Id, What.Name, Description from Task WHERE AccountId = :recordId AND WhoId = '' AND (Activitydate <= 2022-08-27 OR Activitydate = null)]) { taskEventList.add(new eEventTTask(t.Subject, t.CreatedDate, 'T', t.What.Name, t.Owner.Name, t.Id, t.What.Id, 'standard:task', t.Status, t.Who.Name, t.Who.Id, t.Description)); } // Abfrage von Aufgaben/Tasks ab 01.08.2022 - danach wurde das neue Addin akiviert und somit werden leider für jede email die abgelegt wird eine EmailMessage und Task angelegt //for (Task t: [SELECT Id, Subject, ActivityDate, What.Name, What.Id, Owner.Name, Status, Who.Name, Who.Id FROM Task WHERE Activitydate > 2022-08-26 AND TaskSubType != 'Email' AND Id IN (SELECT TaskId FROM TaskRelation WHERE RelationId = :recordId)]) { for (Task t: [SELECT Id, Subject, ActivityDate, CreatedDate, Createdby.Name, Owner.Name, RecordType.Name, Status, Who.Name, Who.Id, What.Name, Description from Task WHERE AccountId = :recordId AND WhoId = '' AND Activitydate > 2022-08-27 AND TaskSubType != 'Email']) { taskEventList.add(new eEventTTask(t.Subject, t.CreatedDate, 'T', t.What.Name, t.Owner.Name, t.Id, t.What.Id, 'standard:task', t.Status, t.Who.Name, t.Who.Id, t.Description)); } // Abfrage von Aufgaben/Tasks - in dieser Abfrage werden alle Aufgaben von AG-Kontakten selektiert die diesem Unternehmen zugeordnet sind Map<Id, TaskWhoRelation> relatedTasksAcc = new Map<Id, TaskWhoRelation>([SELECT taskId FROM TaskWhoRelation WHERE AccountId = :recordId AND RelationId IN (SELECT Id FROM Contact WHERE RecordTypeId = '012b0000000UNQxAAO')]); Set<Id> taskidsset = new Set<Id>(); for(taskwhorelation relation:relatedTasksAcc.values()) { taskidsset.add(relation.taskid); } system.debug('size relatedtasksAcc ' +relatedtasksAcc.size()); system.debug('size taskidsset ' +taskidsset.size()); List<Task> listtask1 = [SELECT Id, Subject, CreatedDate, ActivityDate, What.Name, What.Id, Owner.Name, Status, Who.Name, Who.Id, Description FROM Task WHERE (Activitydate <= 2022-08-27 OR Activitydate = null) AND Id IN :taskidsset]; system.debug('size listtask1 ' +listtask1.size()); for(Task t : listtask1) { taskEventList.add(new eEventTTask(t.Subject, t.CreatedDate, 'T', t.What.Name, t.Owner.Name, t.Id, t.What.Id, 'standard:task', t.Status, t.Who.Name, t.Who.Id, t.Description)); } List<Task> listtask2 = [SELECT Id, Subject, CreatedDate, ActivityDate, What.Name, What.Id, Owner.Name, Status, Who.Name, Who.Id, Description FROM Task WHERE Activitydate > 2022-08-27 AND TaskSubType != 'Email' AND Id IN :taskidsset]; system.debug('size listtask2 ' +listtask2.size()); for(Task t : listtask2) { taskEventList.add(new eEventTTask(t.Subject, t.CreatedDate, 'T', t.What.Name, t.Owner.Name, t.Id, t.What.Id, 'standard:task', t.Status, t.Who.Name, t.Who.Id, t.Description)); } // Abfrage von Termine/Events - in dieser Abfrage werden alle Termine von AG-Kontakten selektiert die diesem Unternehmen zugeordnet sind Map<Id, EventWhoRelation> relatedEventAcc = new Map<Id, EventWhoRelation>([SELECT EventId FROM EventWhoRelation WHERE AccountId = :recordId and RelationId IN (SELECT Id FROM Contact WHERE RecordTypeId = '012b0000000UNQxAAO')]); Set<Id> eventidsset = new Set<Id>(); for(eventwhorelation relation:relatedEventAcc.values()){ eventidsset.add(relation.eventid); } system.debug('size relatedeventAcc ' +relatedeventAcc.size()); system.debug('size eventidsset ' +eventidsset.size()); List<Event> listevent = [SELECT Id, Subject, ActivityDate, ActivityDatetime, What.Name, What.Id, Owner.Name, Who.Name, Who.Id FROM Event WHERE Id IN :eventidsset]; system.debug('size listevent ' +listevent.size()); for(event e : listevent) { taskEventList.add(new eEventTTask(e.Subject, e.ActivityDatetime, 'E', e.What.Name, e.Owner.Name, e.Id, e.What.Id, 'standard:event', '', e.Who.Name, e.Who.Id, e.Subject)); } // 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, c.ContentDocument.CreatedDate, 'C', c.LinkedEntity.Name, c.ContentDocument.CreatedBy.Name, c.ContentDocumentId, c.LinkedEntity.Id, 'standard:file', '', '', '', c.ContentDocument.Title)); } for(ContentDocumentLink c: [SELECT Id, ContentDocumentId, ContentDocument.Title, ContentDocument.createdDate, ContentDocument.Createdby.Name, ContentDocument.FileExtension, LinkedEntity.Id, LinkedEntity.Name FROM ContentDocumentLink WHERE LinkedEntityId IN (SELECT Id FROM Contact WHERE AccountId =: recordId)]) { taskEventList.add(new eEventTTask(c.ContentDocument.Title, c.ContentDocument.CreatedDate, 'C', c.LinkedEntity.Name, c.ContentDocument.CreatedBy.Name, c.ContentDocumentId, c.LinkedEntity.Id, 'standard:file', '', '', '', c.ContentDocument.Title)); } // 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, a.CreatedDate, 'A', a.Parent.Name, a.Owner.Name, a.Id, a.ParentId, 'standard:note', '', '', '', a.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 IN (SELECT Id FROM Contact WHERE AccountId =: recordId and RecordTypeId = '012b0000000UNQxAAO')]) { taskEventList.add(new eEventTTask(a.Name, a.CreatedDate, 'A', a.Parent.Name, a.Owner.Name, a.Id, a.ParentId, 'standard:note', '', '', '', a.Name)); } // 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, n.CreatedDate, 'N', n.Parent.Name, n.Owner.Name, n.Id, n.ParentId, 'standard:note', '', '', '', n.Title)); } // Abfrage von Notizen/Notes for(Note n: [SELECT Id, Title, CreatedDate, Createdby.Name, Owner.Name, Parent.Name, ParentId FROM Note WHERE ParentId IN (SELECT Id FROM Contact WHERE AccountId = :recordId AND RecordTypeId = '012b0000000UNQxAAO')]) { taskEventList.add(new eEventTTask(n.Title, n.CreatedDate, 'N', n.Parent.Name, n.Owner.Name, n.Id, n.ParentId, 'standard:note', '', '', '', n.Title)); } // Abfrage von Email-Messages for (EmailMessage m: [SELECT Id, Subject, MessageDate, RelatedToId, RelatedTo.Name, CreatedBy.Name, HtmlBody FROM EmailMessage WHERE RelatedToId = :recordId]) { taskEventList.add(new eEventTTask(m.Subject, m.MessageDate, 'M', m.RelatedTo.Name, m.CreatedBy.Name, m.Id, m.RelatedToId, 'standard:email', '', '', '', m.HtmlBody)); } // Abfrage von Email-Messages for (EmailMessageRelation m: [SELECT Id, EmailMessageId, EmailMessage.Subject, EmailMessage.MessageDate, EmailMessage.RelatedToId, EmailMessage.RelatedTo.Name, EmailMessage.CreatedBy.Name, Relation.Name, EmailMessage.HtmlBody FROM EmailMessageRelation WHERE RelationId IN (SELECT Id FROM Contact WHERE AccountId = :recordId AND RecordTypeId = '012b0000000UNQxAAO')]) { taskEventList.add(new eEventTTask(m.EmailMessage.Subject, m.EmailMessage.MessageDate, 'M', m.EmailMessage.RelatedTo.Name, m.EmailMessage.CreatedBy.Name, m.EmailMessage.Id, m.EmailMessage.RelatedToId, 'standard:email', '', m.Relation.Name, m.RelationId, m.EmailMessage.HtmlBody)); system.debug('Name --> ' + m.Relation.Name); } // Abfrage von Wiedervorlagen // for(Wiedervorlage__c w: [SELECT Id, Beschreibung__c, Erinnerungstermin__c, Wiedervorlage_f_r__c, Wiedervorlage_f_r_Name__c, Wiedervorlage_f_r_Id__c, Owner.Name FROM Wiedervorlage__c WHERE Wiedervorlage_f_r_Id__c = :recordId]) { // taskEventList.add(new eEventTTask(w.Beschreibung__c, w.Erinnerungstermin__c, 'W', w.Wiedervorlage_f_r_Name__c, w.Owner.Name, w.Id, '', 'standard:today', '', w.Wiedervorlage_f_r_Name__c, w.Wiedervorlage_f_r_Id__c, w.Beschreibung__c)); // } } //########################### ACCOUNT ENDE ################################## system.debug('taskEventList' + taskEventList); return taskEventList; } public class eEventTTask { @AuraEnabled public String ThemaOut {get; set;} @AuraEnabled public Datetime DatumOut {get; set;} @AuraEnabled public String ArtOut {get; set;} @AuraEnabled public String BezugOut {get; set;} @AuraEnabled public String ZugewiesenOut {get; set;} @AuraEnabled public String ThemaIdOut {get; set;} @AuraEnabled public String BezugIdOut {get; set;} @AuraEnabled public String ArtPicOut {get; set;} @AuraEnabled public String StatusPicOut {get; set;} @AuraEnabled public String KontaktOut {get; set;} @AuraEnabled public String KontaktIdOut {get; set;} @AuraEnabled public String TooltipOut {get; set;} public eEventTTask(String ThemaIn, Datetime DatumIn, String ArtIn, String BezugIn, String ZugewiesenIn, String ThemaIdIn, String BezugIdIn, String ArtPicIn, String StatusIn, String KontaktIn, String KontaktIdIn, String TooltipIn) { ThemaOut = ThemaIn; DatumOut = DatumIn; ArtOut = ArtIn; BezugOut = BezugIn; ZugewiesenOut = ZugewiesenIn; IF(ThemaIdIn != Null) { ThemaIdOut = '/' + ThemaIdIn; } IF(BezugIdIn != Null) { BezugIdOut = '/' + BezugIdIn; } ArtPicOut = ArtPicIn; IF(ArtIn == 'm' || ArtIn == 'n' || ArtIn == 'c' || ArtIn == 'a' || (ArtIn == 'e' && DatumIn <= date.today()) || (ArtIn == 't' && (StatusIn == 'Completed' || StatusIn == 'Fertiggestellt'))) { StatusPicOut = 'custom:custom6'; } //grün ELSE IF ((ArtIn == 'e' && DatumIn > date.today()) || // (ArtIn == 'w' && DatumIn > date.today()) || (ArtIn == 't' && DatumIn > date.today() && StatusIn != 'Fertiggestellt' && StatusIn != 'Completed')) { StatusPicOut = 'custom:custom4'; } // gelb ELSE IF ((ArtIn == 't' && DatumIn <= date.today() && (StatusIn != 'Fertiggestellt' || StatusIn != 'Completed')) || (ArtIn == 'w' && DatumIn <= date.today())) { StatusPicOut = 'custom:custom49'; } // rot KontaktOut = KontaktIn; IF(KontaktIdIn != '' && KontaktIdIn != Null) { KontaktIdOut = '/' + KontaktIdIn; } TooltipOut = TooltipIn; } } }
The code of my component how it is rn is the following:
<aura:component controller="AccountSearchController" implements="force:appHostable,flexipage:availableForAllPageTypes" access="global"> <aura:attribute name="accountList" type="Account[]" /> <aura:attribute name="PaginationList" type="Account[]"/> <aura:attribute name="perPageSize" type="Integer" default="5"/> <aura:attribute name="totalRecords" type="Integer"/> <aura:attribute name="startValue" type="Integer" /> <aura:attribute name="endValue" type="Integer"/> <aura:attribute name="columns" type="List"/> <aura:attribute name="sortBy" type="String"/> <aura:attribute name="sortDirection" type="String"/> <aura:attribute name="isLastPage" type="Boolean"/> <aura:handler name="init" action="{!c.doInit}" value="{!this}"/> <!-- Ergebnisse + Pagination--> <div class="slds-grid slds-grid_vertical"> <lightning:datatable data="{!v.PaginationList}" columns="{!v.columns}" keyField="Id" sortedBy="{!v.sortBy}" hideCheckboxColumn="true"/> <lightning:buttongroup> <lightning:button onclick="{!c.previous}" disabled="{!v.startValue == 0}" label="Previous" iconName='utility:back'/> <lightning:button onclick="{!c.next}" disabled="{!v.isLastPage}" label="Next" iconName='utility:forward'/> </lightning:buttongroup> </div> </aura:component>
({ doInit : function(component, event, helper) { var action = component.get('c.searchAccounts'); action.setCallback(this, function(response) { var state = response.getState(); component.set('v.accountList', response.getReturnValue()); console.log(component.get('v.accountList')); //total number of accounts recieved----------------------------------------- var lengthVar = component.get("v.accountList").length; console.log('length///'+lengthVar); component.set("v.totalRecords",lengthVar); //--------------------------------------------------------------------------- //number of records in each page--------------------------------------------- var perPage = component.get("v.perPageSize"); //--------------------------------------------------------------------------- var values=[]; console.log('perPage///'+perPage); //If total number of records are more than 5 or equals 5----------------------- if(lengthVar >= perPage){ for(var i=0;i<perPage;i++){ values.push(response.getReturnValue()[i]); } }//-------------------------------------------------------------------------- else{//If total number of records are lesser than 5-------------------------- for(var i=0;i<lengthVar;i++){ values.push(response.getReturnValue()[i]); } }//-------------------------------------------------------------------------- console.log('values///'+values); component.set("v.PaginationList",values); component.set("v.startValue",0); //if there are only 5 records or lesser than that in total------------------- if(lengthVar <= (component.get("v.startValue")+perPage)){ component.set("v.isLastPage",true); } component.set("v.endValue",component.get("v.startValue")+perPage-1); }); $A.enqueueAction(action); component.set('v.columns', [{label: 'Name', fieldName: 'Name', type: 'text'} ]); }, previous : function(component, event, helper){ component.set("v.isLastPage",false); var sObjectList = component.get("v.accountList"); console.log('sObjectList///',sObjectList); var startValue=component.get("v.startValue"); var endValue=component.get("v.endValue"); var perPage = component.get("v.perPageSize"); console.log('startValue///',startValue); console.log('endValue///',endValue); var totalRecords = component.get("v.totalRecords"); var values=[]; for(var i=startValue-perPage;i<startValue;i++){ console.log('i'+i); values.push(sObjectList[i]); } component.set("v.PaginationList",values); component.set("v.startValue",startValue-perPage); component.set("v.endValue",startValue-1); console.log('start value////'+component.get("v.startValue")); console.log('end value////'+component.get("v.endValue")); }, next : function(component, event, helper){ var sObjectList = component.get("v.accountList"); console.log('sObjectList///',sObjectList); var startValue=component.get("v.startValue"); var endValue=component.get("v.endValue"); var perPage = component.get("v.perPageSize"); console.log('startValue///',startValue); console.log('endValue///',endValue); var totalRecords = component.get("v.totalRecords"); var values=[]; //for eg------------------------------------------------------------------------- // this is page 2 and there are 10 records // endValue is 4 //if total no. of records == 4+5+1 (i.e. 10) //Or if total no. of records > 10, then evaluate this part---------------------- if(totalRecords >= endValue+perPage+1){ for(var i=endValue+1;i<endValue+perPage+1;i++){ values.push(sObjectList[i]); } if(totalRecords == endValue+perPage+1){//if total records == 4+5+1----------- component.set("v.isLastPage",true); } }//------------------------------------------------------------------------------ else{//if total number of records are lesser than 4+5+1(10) i.e. 8 for(var i=endValue+1;i<totalRecords;i++){ values.push(sObjectList[i]); } component.set("v.isLastPage",true); }//------------------------------------------------------------------------------ component.set("v.PaginationList",values); component.set("v.startValue",endValue+1); component.set("v.endValue",endValue+perPage); console.log('start value////'+component.get("v.startValue")); console.log('end value////'+component.get("v.endValue")); } })
ublic class AccountSearchController { @auraEnabled public static List <Account> searchAccounts() { return [SELECT Name,annualrevenue,accountnumber FROM Account LIMIT 8]; } }
- Jonathan Wolff 7
- November 25, 2022
- Like
- 0
Update field with old uploaded Ids by trigger
Hello, I have a trigger on ContentDocumentLink. When a file is uploaded the trigger populates a field. The problem is, that I need to reupload the Ids in every record now. Could you tell me an option so i can populate if with the latest Id in every record?
trigger ContentIdEintragen on ContentDocumentLink (after insert) { map<id,id> parentids = new map<id,id>(); for(ContentDocumentLink cdl:trigger.new){ parentids.put(cdl.LinkedEntityId,cdl.ContentDocumentId); } List<Mediathek__c> ContentDocumentIdupdate = new List<Mediathek__c>(); for(Mediathek__c mt:[select id from Mediathek__c where id IN:parentids.keyset()]){ if(parentids.containskey(mt.id)){ mt.ContentDocumentID__c = parentids.get(mt.id); ContentDocumentIdupdate.add(mt); } } update ContentDocumentIdupdate; }
- Jonathan Wolff 7
- November 23, 2022
- Like
- 0
Error in Apex trigger code: IN operator must be used with an iterable expression
Hello, a developer helped me creating a apex trigger, but i still have the error: IN operator must be used with an iterable expression
Could you tell me how to fix this error? :)
Could you tell me how to fix this error? :)
trigger ContentDocumentIdTrigger on ContentDocumentLink(after insert){ map<id,id> parentids = new map<id,id>(); for(ContentDocumentLink cdl:trigger.new){ parentids.put(cdl.LinkedEntityId,cdl.ContentDocumentId); } List<Mediathek__c> ContentDocumentIdupdate = new List<Mediathek__c>(); for(Mediathek__c mt:[select id, from Mediathek__c where id IN:parentids]){ if(parentids.containskey(mt.id)){ mt.ContentDocumentID__c = parentids.get(mt.id); ContentDocumentIdupdate.add(mt); } } update ContentDocumentIdupdate; }
- Jonathan Wolff 7
- November 21, 2022
- Like
- 0
Error on ContentDocument Trigger
Hello, I tried to build a trigger myself. I have a custom Object Mediathek__c with a custom field ContentDocumentId__c. I want to achive that, when a new file is uploaded to a record of this object, the contentDocumentId of the file is safed within the field.
My try:
My try:
trigger ContentDocumentIdTrigger on ContentDocumentId ( after insert, after update, after delete ) { List<ContentDocumentId> cdid = ( Trigger.new == null ? Trigger.old : Trigger.new ); for ( ContentDocumentId cdid : cdid ) { parentIds.add( cdl.LinkedEntityId ); } for ( List<Mediathek__c> media : [ SELECT Id, ( SELECT Id FROM ContentDocument LIMIT 1 ) FROM Mediathek__c ] ) { for ( Mediathek__c m : media ) { m.ContentDocumentID__c = ( m.ContentDocumentId ); } update media; } }
- Jonathan Wolff 7
- November 21, 2022
- Like
- 0
Display fields from two different objects in a single column of a datatable?
Hello, so I try to create a datatable component that displays tasks and events of a contact in a single table.
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:
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; } }
- Jonathan Wolff 7
- August 04, 2022
- Like
- 1
Problem when using <analytics:reportChart >
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?
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?
- Jonathan Wolff 7
- January 24, 2022
- Like
- 1
Guide to monitor report export with Event Log In
Hello, I would like to track the exports of the reports. Could you tell me how I can achive this by using Event Monitoring. I did not really understand the requirements and steps on trailblazer
- Jonathan Wolff 7
- August 16, 2021
- Like
- 1
Account fields do not display after adding Visualforce in List Button
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>
Result:
<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>
Result:
- Jonathan Wolff 7
- July 08, 2021
- Like
- 1
Error on ContentDocument Trigger
Hello, I tried to build a trigger myself. I have a custom Object Mediathek__c with a custom field ContentDocumentId__c. I want to achive that, when a new file is uploaded to a record of this object, the contentDocumentId of the file is safed within the field.
My try:
My try:
trigger ContentDocumentIdTrigger on ContentDocumentId ( after insert, after update, after delete ) { List<ContentDocumentId> cdid = ( Trigger.new == null ? Trigger.old : Trigger.new ); for ( ContentDocumentId cdid : cdid ) { parentIds.add( cdl.LinkedEntityId ); } for ( List<Mediathek__c> media : [ SELECT Id, ( SELECT Id FROM ContentDocument LIMIT 1 ) FROM Mediathek__c ] ) { for ( Mediathek__c m : media ) { m.ContentDocumentID__c = ( m.ContentDocumentId ); } update media; } }
- Jonathan Wolff 7
- November 21, 2022
- Like
- 0
Create a class to populate a custom field with latest ContentDocumentId
Hello, I want to ave an apex class/trigger, that populates a custom field on my record with the contentdocumentId of the latest uploaded record. Is there any possibility?
I would be glad if you could show me a code sample.
Greetings
Jonathan
I would be glad if you could show me a code sample.
Greetings
Jonathan
- Jonathan Wolff 7
- November 16, 2022
- Like
- 0
Error: method in controller cannot be found
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?
My code ist as follows
Component:
Controller
Apex Controller
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; } }
- Jonathan Wolff 7
- August 04, 2022
- Like
- 0
Create a button to start XLSX-Genarator Apex
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:
The XLSXGenarator code is:
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; } }
- Jonathan Wolff 7
- May 05, 2022
- Like
- 0
Aura:if does not worked like hoped
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> <a href="{!'mailto:' + v.OwnerUser.Vertretung__c.Email}"><lightning:icon iconName="action:email" size="xx-small" alternativeText="E-Mail" title="E-Mail" /></a> <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>
- Jonathan Wolff 7
- April 25, 2022
- Like
- 0
Create test class for campaign apex class
Hello, I tried to make a test class for my apex but I still get errors.
Could you give me some support:
Apex class
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]
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(); } }
- Jonathan Wolff 7
- March 17, 2022
- Like
- 0
Get record Id from flow to apex class
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:
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; } }
- Jonathan Wolff 7
- March 04, 2022
- Like
- 0
Test class for pdf creation Apex
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; } }
- Jonathan Wolff 7
- February 03, 2022
- Like
- 0
Save report at end of month as pdf and only include lines which were created in the Month
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
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
- Jonathan Wolff 7
- January 20, 2022
- Like
- 0
Problem when having Who.Name field in datatable and record with empty field
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?
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);
- Jonathan Wolff 7
- December 10, 2021
- Like
- 0
Error by using Who.Name of tasks in datatable
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?
My code:
APEX
JS
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);
- Jonathan Wolff 7
- December 09, 2021
- Like
- 0
Getting Who.Name into datatable
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:
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:
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);
- Jonathan Wolff 7
- December 06, 2021
- Like
- 0
Creating Apex with PageReference.getContentAsPDF() to create pdf in flow
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:
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>
- Jonathan Wolff 7
- November 29, 2021
- Like
- 0
What do I have to change before CORS update
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
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
- Jonathan Wolff 7
- November 08, 2021
- Like
- 0