Skip to content

Commit

Permalink
#1570: improve how missing default fields are checked for
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Aug 26, 2024
1 parent 78e7a75 commit d4296cd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion @types/lib/metadataTypes/Event.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions lib/metadataTypes/Event.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,15 @@ class Event extends MetadataType {
`Found ${referenceObjectsFieldsResponse?.sfobjectfields?.length} fields for Salesforce Object ${objectAPIName}`
);
this.sfObjects.objectFields[objectAPIName] = {};
// !add default fields that are somehow not always returned by this legacy beta API
for (const field of this.defaultSalesforceFields) {
// @ts-expect-error hack to work around shortcomings of legacy beta API
this.sfObjects.objectFields[objectAPIName][field] = {
label: field,
name: field,
};
}
// add fields returned by API
for (const field of referenceObjectsFieldsResponse.sfobjectfields) {
this.sfObjects.objectFields[objectAPIName][field.name] = field;
}
Expand Down Expand Up @@ -649,10 +658,7 @@ class Event extends MetadataType {
} else {
// check if the fields selected in the eventDefinition are actually available
for (const fieldName of object.fields) {
if (
!this.sfObjects.objectFields[referencedObject][fieldName] &&
!this.defaultSalesforceFields.includes(fieldName)
) {
if (!this.sfObjects.objectFields[referencedObject][fieldName]) {
if (
(referencedObject === 'Contact' || referencedObject === 'Lead') &&
this.sfObjects.objectFields['Contacts and Leads'][fieldName]
Expand Down Expand Up @@ -732,14 +738,14 @@ class Event extends MetadataType {
if (
relationshipName !== 'Contact' &&
referenceObject === 'Contact' &&
!this.sfObjects.objectFields[referenceObject][fieldName]
!this.sfObjects.objectFields[referenceObject][fieldName] &&
this.sfObjects.objectFields['Common']
) {
// basically, when we link to Contact indirectly through other fields then the whole "common" thing does not apply but we still moved the fields to common
referenceObject = 'Common';
}
if (
!this.sfObjects.objectFields[referenceObject][fieldName] &&
!this.defaultSalesforceFields.includes(fieldName) &&
relationshipName !== 'Contact' &&
referenceObject === 'Contact' &&
!this.sfObjects.objectFields['Common'][fieldName]
Expand Down

0 comments on commit d4296cd

Please sign in to comment.