I am trying to get the Url of a file in the File field, but it does not seem to get it. Is this data not accessible via automations or am I doing something wrong?
const fibery = context.getService('fibery');
const utils = context.getService('utils');
const ids = args.currentEntities.map(e => e.id);
if (ids.length === 0) {
return 'No entities selected';
}
// Retrieve File field for all selected entities in one call
const entities = await fibery.getEntitiesByIds('Breakfast at TIFFanys/TIFFs', ids, ['File']);
const urls = [];
for (const ent of entities) {
const fileField = ent['File'];
if (!fileField) {
continue;
}
// The File field may be a single file object or a collection; handle both cases
const files = Array.isArray(fileField) ? fileField : [fileField];
for (const f of files) {
if (f && f.Secret) {
urls.push(utils.getFileUrl(f.Secret));
}
}
}
if (urls.length === 0) {
return 'No file URLs found';
}
return `File URLs:\n${urls.join('\n')}`;