Tutorials

1- Creating the Expense Document Type

Updated: March 18, 2024

This document is part of the Sub Workflow Example project series.

What Will We Do in This Step?

We will create the document type on which the workflow will be launched.

Reviewing the Rules

Before starting the document type creation, we will take a little time to review what is expected from us at this step:

  • Users should be able to fill in their expenses and attach the corresponding receipt. => This means we need to create a document type that will allow us to attach a binary file. The file will be a mandatory field.

  • Each expense should be validated separately. => No more than one binary file at a time then.

  • Expense type can be chosen from a list (transportation, hotel or misc). => We will need to create a vocabulary.

  • Expenses worth 100 dollars or more and/or belonging to the misc type have to be validated by the accounting service and the general manager, otherwise only by the accounting service. => The user will have to fill the amount; amount and expense type should be mandatory fields.

Alright; now that we know where we are heading to, we can look further.

Creating the Vocabulary

Before creating the document type, we will create the vocabulary so that we have all necessary elements to complete it afterwards.

  1. In Nuxeo studio, go to Vocabularies and click on the New button.
  2. Name your vocabulary: expenseType.
  3. Leave the default vocabulary type, a simple vocabulary is exactly what we need.
  4. Add the following entries into the vocabulary (leave the default values for elements not indicated in the table):

    IdLabel
    HotelHotel
    TransportationTransportation
    MiscMisc
  5. Save your vocabulary. You can take a look at the expected result below:

Creating the Expense Document Type

On to the document type creation.

  1. In Nuxeo Studio, go to Content Model > Document Types, and click on the New button.
  2. Fill in the fields:

    • Feature ID: Expense
    • Extends: Choose "Nothing"
    • Label: Expense
  3. Click on the Ok button.

Defining the Document Type

Now that the document type is created, we have to define its specificities.

Definition Tab

  1. Set the category to Document.
  2. (Optional) You may add icons if you like to, your document type will be nicer that way.
  3. Save your modifications. Look at the result below:

Schema Tab

We will need to add two specific fields: amount and type.

  1. In the Add extra schemas to this document type section, add the file schema (not files). Our document will now be able to hold a single binary file.
  2. In the Add a custom schema section:
    • Add a field named amount of type Floating point.
    • Add a field named expensetype of type String.
  3. Save your modifications.

Defining the Document Type Layouts

  1. In the Creation Layout tab, create the layout as following:

    SchemaFieldWidget typeRequired?
    dublincoretitleTextYes
    dublincoredescriptionTextareaNo
    expenseamountFloating pointYes
    expenseexpensetypeVocabulary (use the expenseType vocabulary here!)Yes
    filecontentFileYes
  2. Import this (create) layout in the Edit Layout and View Layout tabs.
  3. Save your modifications. See the result:

Our document type is ready to rock!