Create new action
- Let's imagine sometimes timelog doesn't have enough information about what was done and need to be elaborated.
- For this let's create a new action called "Elaborate".
- In VS Code - open the file actions/index.ts and add one more action at the end:
{
caption: 'Elaborate',
description: 'Ask developer for more details about this timelog',
options: {
showAsButton: false,
viewMode: 'local',
visible: true,
},
priority: 1,
uid: 'elaborate',
},
- Install the app - this will show additional button on timelog.
- Imagine we need to allow this action only for the workspace admin, this can be achieved by adding a precondition:
{
caption: 'Elaborate',
description: 'Ask developer for more details about this timelog',
options: {
showAsButton: false,
viewMode: 'local',
visible: true,
},
precondition: `currentUser.isWorkspaceAdmin`,
priority: 1,
uid: 'elaborate',
},
- This button can be now clicked - but nothing valuable happens. As an example - upon clicking this button - let's create a new task for the user asking for timelog elaboration.
- In VS Code - open the file actions/server-code/index.ts and add such a method.
elaborate() {
const newTask = Cmw.CreateAppRecord('TASK', {
accountable_account_id: currentUser.id,
keeper_id: entity.accountable_account_id,
priority: 'low',
refer_task_id: entity.id,
title: `Need more details about timelog #${entity.number}`,
});
entity.comment = `Requested elaboration about this timelog in task #${newTask.number}`;
}
- Please note to update import line #1 to include "Cmw" and "currentUser".
- Publish the app, then go to some timelog and click "Elaborate" button. Upon clicking a new task will be created.
