Skip to content

Commit

Permalink
Fix #108 handle address field properly in inspect
Browse files Browse the repository at this point in the history
  • Loading branch information
Dufgui authored and dufoli committed May 21, 2024
1 parent 56d93a6 commit 950084b
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion addon/setup-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,33 @@ 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;
const replaceQualifierNameBySuffixOfAddressField = {
"City": "Address",
"CountryCode": "Address",
"GeocodeAccuracy": "Address",
"Latitude": "Address",
"Longitude": "Address",
"PostalCode": "Address",
"StateCode": "Address",
"Street": "Address",
"__City__s": "__c",
"__CountryCode__s": "__c",
"__GeocodeAccuracy__s": "__c",
"__Latitude__s": "__c",
"__Longitude__s": "__c",
"__PostalCode__s": "__c",
"__StateCode__s": "__c",
"__Street__s": "__c",
};
for (const suffixOfAddressField in replaceQualifierNameBySuffixOfAddressField) {
const replaceQualifiedName = replaceQualifierNameBySuffixOfAddressField[suffixOfAddressField];
if (fieldName.endsWith(suffixOfAddressField)) {
qualifiedApiName = qualifiedApiName.replace(suffixOfAddressField, replaceQualifiedName);
break;
}
}
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 950084b

Please sign in to comment.