How to add new business-objects

Speaking about the business object we mean one of the entities that are key to the system. Typically, these entities can be edited via form and usually they have an workflow. In this example, we will look at:

  • Creation of model and view for business-entity with the refence on previously created dictionary entity.
  • Creation of form with grid and edit form for editing business entity
  • Adding permissions for form
  • Adding form to left menu
  • Using function to fill fields with initial values.

1. Creation of model and view for business object

1.1 Execute CreateInvoiceBusinessEntity.sql script. A table with name “Invoice” will be created in your database. 1.2 Open Admin of DWKIT 1.3 Open Data Model section. Click Update model link above of the Data Model grid. In the Updating model tree select “Invoice” table and click Apply button. Data Model item named “Invoice” must be created. 1.4 Open created “Invoice” Data Model object. 1.5 For enable Optimistic locks on this object click on “LockVersion” attribute in the grid with attributes. Change Purpose field from "Normal" to "Field for Versioning". Click Save and Exit button. In Data Model’s edit form select Support optimistic lock check box. Click Save button. Now Optimistic lock for this model is switched on. 1.6 For enable Logical delete on this object click on “IsDeleted” attribute in the grid with attributes. Change Purpose field from "Normal" to "Logical Deleted". Click Save and Exit button. Now Logical delete for this model is switched on. 1.7 Open View section. Click on Create link button above of the View grid.

1.8 Fill Name field with “Invoice” and select “Invoice” Data Model as Model field. Click Save button.

1.9 Now you need to select the columns to be displayed and edited.

NumberId: set Order = 1, Width = 100, Show = checked, Edit = unchecked
InvoiceNumber: set Order = 2, Width = 100, Show = checked, Edit = unchecked
InvoiceDate: set Order = 3, Width = 100, Show = checked, Edit = unchecked
Amount: set Order = 4, Width = 100, Show = checked, Edit = unchecked
State: set Order = 5, Width = 100, Show = checked, Edit = unchecked

Click the Save button.

1.10 Open View section. Click on Create link button above of the View grid. 1.11 Fill Name field with “Invoice_Edit” and select “Invoice” Data Model as Model field. Click Save button. 1.12 Now you need to select the columns to be displayed and edited.

InvoiceNumber: set Order = 2, Width = 100, Show = checked, Edit = checked
Comment: set Order = 3, Width = 150, Show = checked, Edit = checked
InvoiceDate: set Order = 4, Width = 100, Show = checked, Edit = checked
Amount: set Order = 5, Width = 100, Show = checked, Edit = checked
State: set Order = 6, Width = 100, Show = checked, Edit = unchecked
ProjectId: Show = unchecked, Edit = checked

Expand “ProjectId” node:

Name: set Order = 7, Width = 100, Show = checked, Edit = checked, Alternative Name=”Project”

Expand “CreatedBy” node:

Name: set Order = 8, Width = 100, Show = checked, Edit = checked, Alternative Name=”Creator”

Click the Save button.

Screenshots:

Screenshot 1 Screenshot 2 Screenshot 3

2. Creation of form with grid for view business objects

2.1 Open Form section. Click on Create link button above of the Form grid. 2.2 Fill Name field with “Invoice” and Caption field with “Invoices”. Click the Save button. 2.3 To add new Block in this Form click on Create link button above of the Blocks grid. 2.4 Fill Name field with “Main”, choose “Dictionary form” as Template. Click on Load params button near Template params label.

You will see:

@Prefix=form
@ViewName=
@EditFormName=
@CopyFormName=
@AddFormName=

in Template params field. Fill this field as:

@Prefix=form
@ViewName=Invoice
@EditFormName=Invoice_Edit
@CopyFormName=Invoice_Edit
@AddFormName=Invoice_Edit

Click the Save and Exit button.

2.5 Open Form section. Click on Create link button above of the Form grid. 2.6 Fill Name field with “Invoice_Edit” and Caption field with “Invoice edit”. Open Invoice_Edit.js and copy functions for saving and validating the form to Source field. Click Save button. 2.7 To add a new Block in this Form click on Create link button above of the Blocks grid. 2.8 Fill Name field with “Title”, choose “Form title”as Template. Click on Load params button near Template params label.

You will see:

@BlockTitle=
@Prefix=form
@ControlForTitle=form_Name_control
@SaveFunction=
@SaveAndExitFunction=
@BackUrl=

in Template params field. Fill this field as:

@BlockTitle=Invoice
@Prefix=form
@ControlForTitle=form_InvoiceNumber_control
@SaveFunction=CurrentFormSave()
@SaveAndExitFunction=CurrentFormSaveExit()
@BackUrl=#/WS/Invoice/GetContent

Click the Save and Exit button.

2.9 To add new Block in this Form click on Create link button above of the Blocks grid. 2.10 Fill Name field with “Edit form”, Order with 10, choose “Edit form” as Template. Click on Load params button near Template params label.

You will see:

@ViewName=
@TemplateName=RowColumns20
@BackFormName=
@GenerateButtons=false
@FormPrefix=form
@BaseEntityIdName=
@BaseEntityIdValue=

in Template params field. Fill this field as:

@ViewName=Invoice_Edit
@TemplateName=RowColumns20

Click the Save and Exit button.

Screenshots:

Screenshot 4 Screenshot 5

3. Adding permissions for form

3.1 Open Form section. Select “Invoice” form in the Forms grid using checkbox in left column. Click on Create permissions link button above of the Form grid. 3.2 Open Security section. Click on Roles point in dropdown menu. Click on “Admins” role record in Roles grid. 3.3 Click on Expand all link button above of the Permissions grid (bottom of Role edit form). Select all checkboxes in “Invoice” group. Click on Access link button above of the Permissions grid.

Screenshots:

Screenshot 6

4. Adding form to left menu

4.1 Open Menu section. Click on Create link button above of the Menu grid. 4.2 Fill Name field with “Invoice”, select "Left" as Type field and select “Invoice” Form as Form field. Click Save and exit button.

Now you can open the grid with “Invoces”, if you click on Create button you will see the from for Invoice edit. But you can’t save it because Creator field is required but not allow to edit. We need to add function for record inititialization to “Invoice_Edit” view.

Screenshots:

Screenshot 7

5. Using function to fill fields with initial values.

5.1 Open View section. Click on “Invoice_Edit” View record in View grid. 5.2 Click on Create link button above of the Functions grid select "Init for Create" as Type field and select “Common.SetValueCommonSettings” Function as Function field.

Fill Parameters field as:

InvoiceDate=DateNow
CreatedBy=CurrentUserId
CreatedBy_Name=CurrentUserName

Click the Save and exit button.

You can use SimpleBusiness.CommonSettings class in your application to change and add new common settings.

5.3 Click on Create link button above of the Functions grid select "Init for Create" as Type field and select “Dictionaries.SetValueRecord” Function as Function field.

Fill Parameters field as:

State=Active
Amount=0

Click Save and exit button.

Now you have the Invoice edit form fills with default values. And you can save and edit Invoice records.