Manipulating the avatar via automation script?

Hi there. I’m trying to generate avatars for my TODO items in fibery using an image generator AI, but I can’t seem to access the Avatar field in an automation script.

When I console.log(entity['Avatar']); in the script, it prints undefined even though that specific entity has an avatar (that I uploaded manually). If I try to fetch the field via the API with const entityWithExtraFields = await fibery.getEntityById(entity.type, entity.id, ['Avatar']);, then triggering the automation displays a “script failed” popup.

Printing out all the keys with console.log(Object.keys(entity)); shows a list of keys without 'Avatar'.

Is this not supported for now? Doesn’t seem like a stretch to support it since a 'Files' field can be manipulated in a script.

2 Likes

Hi @Sandi
For historical reasons Avatar is only label shown on UI, however it is implemented as files collection with name ‘avatar/avatars’.

You can access it via

const fibery = context.getService('fibery');


for (const entity of args.currentEntities) {
    const entityWithExtraFields = await fibery.getEntityById(entity.type, entity.id, ['avatars']);

    console.log(entityWithExtraFields);
}
1 Like

Haven’t tried this yet, but thanks!