Skip to content

Commit

Permalink
Fixes validation script for history records and sourceApiVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
jamessimone committed Mar 20, 2024
1 parent 3b2ef90 commit 2bd6604
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
12 changes: 3 additions & 9 deletions scripts/validate-history-query.apex
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
private class OpportunityFieldHistoryExample extends FieldLevelHistory {
protected override String getParentFieldName() {
return OpportunityFieldHistory.OpportunityId.getDescribe().getName();
}
}

if ([SELECT COUNT() FROM OpportunityFieldHistory] == 0) {
List<Opportunity> opps = [SELECT Id, Name FROM Opportunity LIMIT 1];
if (opps.isEmpty()) {
Expand All @@ -15,6 +9,7 @@ if ([SELECT COUNT() FROM OpportunityFieldHistory] == 0) {
Opportunity opp = opps[0];
opp.Name = 'Something New';
update opp;
System.debug('Updated opportunity to create history record');
} else {
System.debug('Histories already exist, continuing ...');
}
Expand All @@ -23,11 +18,10 @@ Exception ex;
List<FieldLevelHistory> histories;
try {
histories = new FieldLevelHistoryRepo(
OpportunityFieldHistory.OpportunityId,
OpportunityFieldHistory.SObjectType,
OpportunityFieldHistoryExample.class,
new List<Schema.SObjectField>(),
new RepoFactory()
).getAllHistory();
).setParentField(OpportunityFieldHistory.OpportunityId).getAllHistory();
System.debug(histories);
} catch (Exception e) {
ex = e;
Expand Down
4 changes: 2 additions & 2 deletions sfdx-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
],
"namespace": "",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "56.0"
}
"sourceApiVersion": "60.0"
}

0 comments on commit 2bd6604

Please sign in to comment.