Skip to content

Commit 010daef

Browse files
committed
Update count and limit
1. Update record count with where clause 2. Add records with per page
1 parent fd26654 commit 010daef

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

main/default/classes/RelatedList.cls

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ public with sharing class RelatedList {
44
return Database.query(soql);
55
}
66

7-
@AuraEnabled(cacheable = true) public static Integer countRecords(String objectName) {
8-
if(String.isNotEmpty(objectName)) {
9-
return database.countQuery('SELECT count() FROM ' + objectName);
7+
@AuraEnabled(cacheable=true) public static Integer countRecords(String countSOQL) {
8+
if (String.isNotEmpty(countSOQL)) {
9+
return database.countQuery(countSOQL);
1010
}
1111
return 0;
12-
}
12+
}
1313
}

main/default/classes/RelatedList_Test.cls

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public with sharing class RelatedList_Test {
1717
User testUser = [Select id from user where id = :UserInfo.getUserId()];
1818
Test.startTest();
1919
System.runAs(testUser){
20-
RelatedList.countRecords('Contact');
20+
RelatedList.countRecords('Select count() FROM Contact LIMIT 1');
2121
RelatedList.countRecords(null);
2222
}
2323
Test.stopTest();

main/default/lwc/lwcRelatedList/lwcRelatedList.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default class LightningDatatable extends NavigationMixin(
4646
});
4747
this.columns = cols;
4848
this.buildSOQL();
49-
countRecords({ objectName: this.objectName }).then((result) => {
49+
countRecords({ countSOQL: this.buildCountSOQL() }).then((result) => {
5050
this.totalRows = result;
5151
});
5252
this.fetchRecords();

main/default/lwc/lwcRelatedList/lwcRelatedList.js-meta.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
3-
<apiVersion>48.0</apiVersion>
3+
<apiVersion>49.0</apiVersion>
44
<isExposed>true</isExposed>
55
<targets>
66
<target>lightning__RecordPage</target>
@@ -14,6 +14,7 @@
1414
<property name="columns" type="String" required="true" label="Enter Columns JSON"/>
1515
<property name="relatedFieldAPI" type="String" default="" label="Enter Related field API Name"/>
1616
<property name="whereClause" type="String" default="" label="Enter WHERE clause"/>
17+
<property name="limit" type="String" default="10" label="Enter number of records to display on screen"/>
1718
</targetConfig>
1819
</targetConfigs>
1920
</LightningComponentBundle>

0 commit comments

Comments
 (0)