Getting all field values for an entity

Here’s a little scripting snippet for how to retrieve all the infromation about an entity, without knowing or hard-coding the space name, database name or field names:

const fibery = context.getService('fibery');
// get entire schema
const schema = await fibery.getSchema();
// get specific database (type) name
const typeName = args.currentEntities[0].type;
// filter the schema for the specific type and get all field names
const fields = schema['typeObjects'].filter((obj) => obj.name == typeName)[0]['fieldObjects'].map((field) => field.name);
// get all entities with all fields
const entitiesWithAllFields = await fibery.getEntitiesByIds(typeName, args.currentEntities.map((entity) => entity.id), fields);
// send result to the browser console
console.log(entitiesWithAllFields);
1 Like