Scripting works. Doesn’t cause any issues (that i could find) with having the same rank in multiple places, just puts things next to each other in the views, and recalculates automatically when dragged. This is the cleanest solution for the end user.
Down side is the fragility of scripting. Changes in naming fields, space, or database will cause the script to break so i try to avoid scripting when I can. Hence, keeping this feature request open.
Another down side is the fact that newly created tasks don’t go the bottom, instead they are in the middle of everything. I didn’t implement the calculation based on the project id. This could solve it, but I’m more worried this would break things. If the number is too small or something? Could give it a shot and see what happens haha
Got it to work! But its making rank number a lot smaller than usual, so far it doesn’t seem to be a problem! Here’s the script:
// Developer reference is at https://the.fibery.io/@public/User_Guide/Guide/Scripts-in-Automations-54
// Fibery API is used to retrieve and update entities
const fibery = context.getService('fibery');
// affected entities are stored in args.currentEntities;
// to support batch actions they always come in an array
for (const entity of args.currentEntities) {
// an entity contains all fields apart from collections;
// to access a field refer to it by its UI name
const taskTemplateId = entity['Task Template']["Id"];
const taskTemplate = await fibery.getEntityById('Project Management/Task Template', taskTemplateId, ['Order', 'Type 1']);
const taskTemplateRank = taskTemplate['Order'];
const project = await fibery.getEntityById('Project Management/Project', entity['Project']['Id'], ['Public Id']);
const projectId = project['Public Id'];
console.log(taskTemplateRank);
console.log(projectId);
const newRank = Number(projectId + String(taskTemplateRank))*1000;
console.log(newRank)
// to update an entity provide an object with the new values
await fibery.updateEntity(entity.type, entity.id, {
'rank': newRank,
});
}
The down side is that after a certain number of moves it needs to reorder all the cards and assign new ranks. Not sure how long this would take is the database is very large… Could just make the *1000 into *1000000 to accommodate more moves. but still at some point it’ll need to rerank.
Updated:
// Developer reference is at https://the.fibery.io/@public/User_Guide/Guide/Scripts-in-Automations-54
// Fibery API is used to retrieve and update entities
const fibery = context.getService('fibery');
// affected entities are stored in args.currentEntities;
// to support batch actions they always come in an array
for (const entity of args.currentEntities) {
// an entity contains all fields apart from collections;
// to access a field refer to it by its UI name
const taskTemplateId = entity['Task Template']["Id"];
const taskTemplate = await fibery.getEntityById('Project Management/Task Template', taskTemplateId, ['Order', 'Type 1']);
const taskTemplateRank = taskTemplate['Order'];
const project = await fibery.getEntityById('Project Management/Project', entity['Project']['Id'], ['Public Id']);
const projectId = project['Public Id'];
console.log(taskTemplateRank);
console.log(projectId);
const newRank = Number((projectId + String(taskTemplateRank * 1000000000000000)).substring(0, 15));
// to update an entity provide an object with the new values
await fibery.updateEntity(entity.type, entity.id, {
'rank': newRank,
});
}
Edit: the problem with the above is that a ranking of 10 and of 1 will look the same. working script below:
// Developer reference is at https://the.fibery.io/@public/User_Guide/Guide/Scripts-in-Automations-54
// Fibery API is used to retrieve and update entities
const fibery = context.getService('fibery');
// affected entities are stored in args.currentEntities;
// to support batch actions they always come in an array
for (const entity of args.currentEntities) {
// an entity contains all fields apart from collections;
// to access a field refer to it by its UI name
const stageTemplateId = entity['Stage']["Id"];
const stageTemplate = await fibery.getEntityById('Projects/Stage', stageTemplateId, ['Order']);
const stageTemplateOrder = stageTemplate['Order'];
const project = await fibery.getEntityById('Projects/Project', entity['Project']['Id'], ['Public Id']);
const projectId = project['Public Id'];
const paddedOrder = String(stageTemplateOrder).padStart(3, '0');
const newRank = Number((projectId + paddedOrder + '0'.repeat(12)).substring(0, 15));
await fibery.updateEntity(entity.type, entity.id, {
'rank': newRank,
});
}