Create new calculated field
- Let's add a Cost field which will be a calculated field - which will multiply "effort hours" by $100
- For this in fields/index.ts please add this new field:
{
calcType: 'calcfield',
caption: 'Cost',
dependsOn: ['c_is_billable', 'total_real'],
jsCode: `() => (entity.c_is_billable ? entity.total_real * 100 : 0)`,
name: 'c_cost',
options: { formatting_pre: '$' },
renderType: 'number',
},
- And add this field to the layout in views/layouts/dashboard.xml - just after "is billable" field:
<field name="c_is_billable" />
<field name="c_cost" />
- Let's install the app again
npx comind i app-basic-timelog WORKSPACE_ALIAS_HERE
- Finally, see the form on web with this field:
- If you mark "is billable" checkbox - it will auto-calculate Cost field: