Skip to content

Commit

Permalink
Fix dufoli#108 handle address field properly in inspect
Browse files Browse the repository at this point in the history
  • Loading branch information
Dufgui committed May 21, 2024
1 parent 3e89fbe commit 358bc48
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion addon/setup-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,18 @@ function getFieldDefinitionSetupLinks(sfHost, fieldName, fieldDefinition, isCust
}

export async function getFieldSetupLinks(sfHost, sobjectName, fieldName, isCustomSetting) {
let {records: fieldDefinitions} = await sfConn.rest(`/services/data/v${apiVersion}/tooling/query/?q=${encodeURIComponent(`select DurableId from FieldDefinition where EntityDefinition.QualifiedApiName = '${sobjectName}' and QualifiedApiName = '${fieldName}'`)}`);
let qualifiedApiName = fieldName;
let suffixOfAddressFields = ["City", "CountryCode", "GeocodeAccuracy", "Latitude", "Longitude", "PostalCode", "StateCode", "Street"];
let replaceQualifiedName = isCustomSetting ? "__c" : "Address";
for (let suffixOfAddressField of suffixOfAddressFields) {
if (isCustomSetting) {
suffixOfAddressField = "__" + suffixOfAddressField + "__s";
}
if (fieldName.endsWith(suffixOfAddressField)) {
qualifiedApiName = qualifiedApiName.replace(suffixOfAddressField, replaceQualifiedName);
}
}
let {records: fieldDefinitions} = await sfConn.rest(`/services/data/v${apiVersion}/tooling/query/?q=${encodeURIComponent(`select DurableId from FieldDefinition where EntityDefinition.QualifiedApiName = '${sobjectName}' and QualifiedApiName = '${qualifiedApiName}'`)}`);
let isCmdt = sobjectName.endsWith("__mdt");
return getFieldDefinitionSetupLinks(sfHost, fieldName, fieldDefinitions[0], isCustomSetting, isCmdt);
}
Expand Down

0 comments on commit 358bc48

Please sign in to comment.