I have an entity in one Space I want to move to another, would use the Convert to feature but some of the field names may not match.
In its simplest form I want to copy a few simple fields (Name and Salary) from an entity from Space A > Db X to Space B > Db Y .
The part I’m not sure about is how to specify fibery.createEntity
to do so in Space B > Db Y .
Here is what I have so far:
const fibery = context.getService('fibery');
for (const entity of args.currentEntities) {
const name = entity['Name'];
const salary = entity['Salary'];
await fibery.createEntity(entity.type, entity.id, {
// ...
});
}
1 Like
Figured it out but leaving this up here for others reference.
Here is my script equivalent of the Convert to feature but with the ability to map to dissimilarly named fields.
const fibery = context.getService("fibery");
for (const entity of args.currentEntities) {
await fibery.createEntity("Space B/Db Y", {
"Person Name": entity["Name"],
"Person Salary": entity["Salary"],
});
await fibery.deleteEntity(entity.type, entity.id);
}
7 Likes
cover
February 9, 2022, 8:56pm
3
OMG many thanks! Just faced such a goal to achieve and here is handy solution, tx!!!
This just helped me too! Thanks @Dimitri_S !
Joe_H
May 2, 2023, 9:03pm
5
Hey Dimitri,
Any idea how would I do this if I just want to use the convert feature to move from one database to another & the field names are the same via automation script?
I can get it to create the new entity, but I’m duplicating email messages (with attachments & rich text message fields) & am getting errors on the message ID and Files.
Thanks!