@salesforce/core 8.31.1 → 8.31.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/org/org.js +22 -2
- package/package.json +1 -1
package/lib/org/org.js
CHANGED
|
@@ -746,8 +746,28 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
746
746
|
}
|
|
747
747
|
}
|
|
748
748
|
const whereClause = by.id ? `Id='${by.id}'` : `SandboxName='${by.name ?? '<undefined>'}'`;
|
|
749
|
-
const
|
|
750
|
-
|
|
749
|
+
const buildSoql = (fields) => `SELECT ${fields.join(',')} FROM SandboxInfo WHERE ${whereClause} ORDER BY CreatedDate DESC`;
|
|
750
|
+
let soql = buildSoql(sandboxInfoFields);
|
|
751
|
+
let records;
|
|
752
|
+
try {
|
|
753
|
+
records = (await this.connection.tooling.query(soql)).records;
|
|
754
|
+
}
|
|
755
|
+
catch (err) {
|
|
756
|
+
// PostCopyConfig is only available on orgs running a release that exposes the field on
|
|
757
|
+
// the Tooling API. Older orgs reject the SOQL with INVALID_FIELD ("No such column ...").
|
|
758
|
+
// Retry once without PostCopyConfig so existing customers aren't broken.
|
|
759
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
760
|
+
const isInvalidField = (err instanceof Error && err.name === 'INVALID_FIELD') || message.includes('No such column');
|
|
761
|
+
if (isInvalidField && message.includes('PostCopyConfig')) {
|
|
762
|
+
this.logger.debug('PostCopyConfig not supported on this org; retrying SandboxInfo query without it');
|
|
763
|
+
soql = buildSoql(sandboxInfoFields.filter((f) => f !== 'PostCopyConfig'));
|
|
764
|
+
records = (await this.connection.tooling.query(soql)).records;
|
|
765
|
+
}
|
|
766
|
+
else {
|
|
767
|
+
throw err;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
const result = records.filter((item) => !item.IsDeleted);
|
|
751
771
|
if (result.length === 0) {
|
|
752
772
|
throw new sfError_1.SfError(`No record found for ${soql}`, connection_1.SingleRecordQueryErrors.NoRecords);
|
|
753
773
|
}
|