Skip to main content
Skip table of contents

HansaWorld custom field examples

Price List dimension

In the example below, a combination of Price List, Price and Customer registers are used to create 3 level hierarchy.

CODE
[PLVc.F_PriceList]
name = 'Price List Code'
dimension_name = 'Price'
cube_name = 'Hansaworld Invoices'
level_name = 'Price list'
rest_api_field = "PLCode"
key_field = true

[PLVc.F_PriceListName]
name = 'Price List Name'
dimension_name = 'Price'
cube_name = 'Hansaworld Invoices'
level_name = 'Price list'
rest_api_field = "PLCode"
name_field = true

[PLVc.F_PriceItemCode]
name = 'Price Item Code'
dimension_name = 'Price'
cube_name = 'Hansaworld Invoices'
level_name = 'Item'
rest_api_field = "ArtCode"
key_field = true

[PLVc.F_PriceItemName]
name = 'Price Item Name'
dimension_name = 'Price'
cube_name = 'Hansaworld Invoices'
level_name = 'Item'
rest_api_field = "Comment"
name_field = true

[PLVc.F_PriceCustomerCode]
name = 'Price Customer Code'
dimension_name = 'Price'
cube_name = 'Hansaworld Invoices'
level_name = 'Customer'
rest_api_field = "CustCode"
key_field = true

[PLVc.F_PriceCustomerName]
name = 'Price Customer Name'
dimension_name = 'Price'
cube_name = 'Hansaworld Invoices'
level_name = 'Customer'
rest_api_field = "CustCode"
name_field = true

[IVVc.PriceListProperty]
name = "Price list Property"
cube_name = 'Hansaworld Invoices'
data_type = "string"
dimension_name = 'Invoice'
level_name = 'Invoice'
rest_api_field = 'PriceList'

[IVVc.RowPriceListCode]
name = 'Invoice Price List Code'
cube_name = 'Hansaworld Invoices'
for_custom_dimension = 'Price'
for_custom_dimension_level = 'Price list'
bind_field_name = 'F_PriceList'
rest_api_item_field = "rows"
javascript_code = '''
if (doc.rows) {
  doc.rows.forEach(function(row){
    if (doc.PriceList){
      row.RowPriceListCode = doc.PriceList;
    }
  })
}
'''

[IVVc.ArtCode]
name = 'Invoice Item Code'
cube_name = 'Hansaworld Invoices'
for_custom_dimension = 'Price'
for_custom_dimension_level = 'Item'
bind_field_name = 'F_PriceItemCode'
rest_api_item_field = "rows"

[IVVc.RowCustCode]
name = 'Invoice Customer Code'
cube_name = 'Hansaworld Invoices'
for_custom_dimension = 'Price'
for_custom_dimension_level = 'Customer'
bind_field_name = 'F_PriceCustomerCode'
rest_api_item_field = "rows"
javascript_code = '''
if (doc.rows) {
  doc.rows.forEach(function(row){
    if (doc.CustCode){
      row.RowCustCode = doc.CustCode;
    }
  })
}
'''

Project Transaction cube

This is an example on how Project Transaction cube can be build based on SERP data.
This cube definition contains these sections:

  • Defining Project transaction dimensions

  • Binding project transaction to dimensions

  • Defining Project transaction measures

    Note: Cube name is given a name when you import first Custom field

Note: to see re- used standard Dimensions see sections “ for_standard_dimensions”, to see new dimension setup see sections “ for_custom_dimension”

Idea: With Javascript you can manipulate values during import and use them in a different way , see sections “ javascript_code"

CODE
#### Start of project transactions cube ####

#Defining Project transaction dimensions
#--------------------------
[TBIVVc.date]
name = 'Project Transaction Date'
dimension_name = 'Project Transaction'
cube_name = "HansaWorld Project Transactions"
rest_api_field = 'TransDate'
data_type = 'date'
for_standard_dimension = "Time"
import_sort_date = true

[TBIVVc.code]
name = 'Project Transaction Code'
for_custom_dimension = 'Project Transaction'
dimension_name = 'Project Transaction'
cube_name = "HansaWorld Project Transactions"
rest_api_field = 'SerNr'
key_field = true

[TBIVVc.name]
name = 'Project Transaction Name'
for_custom_dimension = 'Project Transaction'
dimension_name = 'Project Transaction'
cube_name = "HansaWorld Project Transactions"
rest_api_field = 'PRName'
name_field = true

[TBIVVc.item_type]
name = 'Project Transaction Item Type'
dimension_name = 'Project Transaction'
cube_name = "HansaWorld Project Transactions"
rest_api_field = 'ItemType'
dimension = true
javascript_code = '''
switch(doc.ItemType) {
  case "0":
    doc.ItemType = "Plain";
    break;
  case "1":
    doc.ItemType = "Stocked";
    break;
  case "3":
    doc.ItemType = "Service";
    break;
  case "5":
      doc.ItemType = "Materials";
    break; }
'''

[TBIVVc.transaction_surce]
name = 'Project Transaction Source'
dimension_name = 'Project Transaction'
cube_name = "HansaWorld Project Transactions"
rest_api_field = 'oVc'
dimension = true
javascript_code = '''
switch(doc.oVc) {
  case "1":
    doc.oVc = "Timesheet";
    break;
  case "2":
    doc.oVc = "Purchase inv.";
    break;
  case "3":
    doc.oVc = "Expense";
    break;
  case "4":
    doc.oVc = "Delivery";
    break;
  case "5":
    doc.oVc = "Activity";
    break;
  case "6":
    doc.oVc = "Ret. goods";
    break;
  case "7":
    doc.oVc = "Depreciation";
    break;
   }
'''

[TBIVVc.invoice_status]
name = 'Project Transaction Invoice Statuss'
dimension_name = 'Project Transaction'
cube_name = "HansaWorld Project Transactions"
skip_request = true
dimension = true
javascript_code = '''
if (doc.Invoice) {
  doc.invoice_status = 'Invoiced'
}
else {
  doc.invoice_status = 'Not Invoiced'
}
'''

[TBIVVc.objects]
name = 'Objects'
dimension_name = 'Project Transaction'
cube_name = "HansaWorld Project Transactions"
rest_api_field = 'Objects'
for_extra_dimension_type = "Object types"

#Binding project transaction to dimensions
#--------------------------

[TBIVVc.invoice_code]
name = 'Project Transaction Invoice Code'
cube_name = "HansaWorld Project Transactions"
for_standard_dimension = 'Invoice'
bind_field_name = 'code'
rest_api_field = 'Invoice'

[TBIVVc.invoice_item_position]
name = 'Project Transaction Invoice Item Position'
cube_name = "HansaWorld Project Transactions"
for_standard_dimension = 'Invoice'
for_standard_dimension_level = 'Invoice Item'
bind_field_name = 'position'
skip_import = true
javascript_code = '''
doc.invoice_item_position = "-1"
'''

[TBIVVc.currency_code]
name = 'Project Transaction Currency Code'
cube_name = "HansaWorld Project Transactions"
for_standard_dimension = 'Currency'
bind_field_name = 'currency'
rest_api_field = 'CurncyCode'

[TBIVVc.project_code]
name = 'Project Transaction Project Code'
cube_name = "HansaWorld Project Transactions"
for_standard_dimension = 'Project (Job)'
for_standard_dimension_level = "Project"
bind_field_name = 'code'
rest_api_field = 'PRCode'

[TBIVVc.project_item_position]
name = 'Project Transaction Project Item Position'
cube_name = "HansaWorld Project Transactions"
for_standard_dimension = 'Project (Job)'
for_standard_dimension_level = 'Project Item'
bind_field_name = 'position'
skip_import = true
javascript_code = '''
doc.project_item_position = "-1"
'''

[TBIVVc.item_code]
name = 'Project Transaction Item Code'
cube_name = "HansaWorld Project Transactions"
for_standard_dimension = 'Item'
bind_field_name = 'code'
rest_api_field = 'ArtCode'

[TBIVVc.person_code]
name = 'Project Transaction Person Code'
cube_name = "HansaWorld Project Transactions"
for_standard_dimension = 'Person'
bind_field_name = 'code'
rest_api_field = 'EMCode'

#Defining Project transaction measures
#--------------------------

[TBIVVc.quantity]
name = "Project Transaction Quantity"
cube_name =  "HansaWorld Project Transactions"
dimension_name = 'Project Transaction'
measure = true
cubes_for_measure_sharing = ["HansaWorld Invoices"]
rest_api_field = "Qty"

[TBIVVc.gross_profit]
name = "Project Transaction Gross Profit"
cube_name =  "HansaWorld Project Transactions"
dimension_name = 'Project Transaction'
cubes_for_measure_sharing = ["HansaWorld Invoices"]
measure = true
rest_api_field = "GP"

[TBIVVc.cost]
name = "Project Transaction Cost"
cube_name =  "HansaWorld Project Transactions"
dimension_name = 'Project Transaction'
measure = true
cubes_for_measure_sharing = ["HansaWorld Invoices"]
skip_request = true
javascript_code = '''
if (doc.CostPrice) {
doc.cost = String(doc.CostPrice * doc.Qty)
}
'''

[TBIVVc.sum]
name = "Project Transaction Amount"
cube_name =  "HansaWorld Project Transactions"
dimension_name = 'Project Transaction'
measure = true
rest_api_field = "Sum"
cubes_for_measure_sharing = ["HansaWorld Invoices"]
javascript_code = '''
doc._source_id = doc.SerNr;
'''

#### End of project transactions cube ####
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.