Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Avoid using SOQL subqueries for query locator error #8

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# RecordClone

Lightning component to clone record with child records together
Lightning component to clone record with child records together.
The managed package is available on _(AppExchange)[https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3u00000MBZZMEA5]_

![Logo](brand-imgs/keyLogo.png)

![Screenshot1](brand-imgs/Screenshot1.png)
![Screenshot2](brand-imgs/Screenshot2.png)
![Screenshot3](brand-imgs/Screenshot3.png)
![Screenshot4](brand-imgs/Screenshot4.png)
![Screenshot5](brand-imgs/Screenshot5.png)
![Screenshot6](brand-imgs/Screenshot6.png)
12 changes: 12 additions & 0 deletions force-app/main/default/classes/CloneQueryResult.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public class CloneQueryResult {
public CloneQueryResult(
sObject parent,
Map<String, List<sObject>> childrens
) {
this.parent = parent;
this.childrens = childrens;
}

public sObject parent;
public Map<String, List<sObject>> childrens;
}
5 changes: 5 additions & 0 deletions force-app/main/default/classes/CloneQueryResult.cls-meta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>51.0</apiVersion>
<status>Active</status>
</ApexClass>
11 changes: 6 additions & 5 deletions force-app/main/default/classes/RecordCloneController.cls
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,19 @@ global with sharing class RecordCloneController {
}

// get the original record
sObject originalRecord = RecordCloneHandler.getOriginalRecord(
CloneQueryResult queryResult = RecordCloneHandler.getOriginalRecord(
recordId,
sObjSummary
);

if (originalRecord == null) {
if (queryResult == null) {
return null;
}

// exec clone
sObject clonedRecord = RecordCloneHandler.cloneRecord(
originalRecord,
queryResult.parent,
queryResult.childrens,
sObjSummary,
newParentRecordName,
childRecordNameType
Expand Down Expand Up @@ -118,14 +119,14 @@ global with sharing class RecordCloneController {
sObjectSummary sObjSummary = sObjectSummary.getByRecordId(rids[0]);

// get original records
List<sObject> originalRecords = RecordCloneHandler.getOriginalRecords(
List<CloneQueryResult> cloneQueryResults = RecordCloneHandler.getOriginalRecords(
rids,
sObjSummary
);

// exec clone
Map<Id, sObject> clonedRecords = new Map<Id, sObject>(
RecordCloneHandler.cloneRecords(originalRecords, sObjSummary)
RecordCloneHandler.cloneRecords(cloneQueryResults, sObjSummary)
);

clonedRecordList.add(new List<Id>(clonedRecords.keySet()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public with sharing class RecordCloneDebugController {
DescribeSObjectResult describe = recordId.getSObjectType().getDescribe();
objectName = describe.getLocalName();
}
System.debug(objectName);
Map<String, String> result = new Map<String, String>();
sObjectType sObjType = (sObjectType) Schema.getGlobalDescribe()
.get(objectName);
Expand Down
Loading