[Quick guide] Assign all children to me

I didn’t see an easy way to do this with the current buttons, so I made it with code.

Demo

Video of setup process

The App name is copied from the one that has the Child, since the child doesn’t necessarily have to be from the same app (hence the redundant navigation to child for App name in the video).
Clear the example code generated, paste this in your Script and fill it out:

const childFieldName = "NAME_OF_CHILD_RELATION";
const foreign = {
    appName: "CHILD_APP_NAME",
    typeName: "CHILD_TYPE_NAME"
}

const fibery = context.getService('fibery');
for (const entity of args.currentEntities) {
    const withAllChildren = await fibery.getEntityById(entity.type, entity.id, [childFieldName]);
    if (!withAllChildren[childFieldName].length) return;

    await Promise.all(
        withAllChildren[childFieldName]
        .map(item => 
            fibery.assignUser(`${foreign.appName}/${foreign.typeName}`, item.Id, args.currentUser.id)
            )
        );
}
8 Likes