Skip to main content

Create new calculated field

  1. Let's add a Cost field which will be a calculated field - which will multiply "effort hours" by $100
  2. 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',
},
  1. 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" />
  1. Let's install the app again
npx comind i app-basic-timelog WORKSPACE_ALIAS_HERE
  1. Finally, see the form on web with this field:
Zero cost
  1. If you mark "is billable" checkbox - it will auto-calculate Cost field:
Real cost