Support > Repository > Repetition > [Application] Managing change history of data with repeating container
ja | en

Here is an example of displaying all change history on arbitrary data on the screen.

When updating is done, you can leave the following record in the log file (logs/system.log).

UpdateCustomer | DoUpdate: 1000 | Value of item 'customer name' in model 'customer' 'Hanako Suzuki' has been changed to 'Sato Hanako'. 
Actually it is outputted as one line.

This function is disabled by default.To enable it, write "CHANGE" in "Screen> Other> Generation management> Leave change history in log".

Figure 1 Enabling the change history function
In addition to changing this setting, logs are output even when values ​​are added and deleted.

Example of operation

Here is an example of displaying all the change history of arbitrary data on the screen by using repeating containers.

Figure 2 Change history is added to top of repeating container

Definition method

Add 5 items to manage change history.(Item name and item ID may be other than those shown here.)

item name Item ID Type Column width Read only
change history changelog Repeat container - -
No changelog/cid Repeating Container ID 5%
Date Time changelog/cdate Date Time 20%
User ID changelog/cuserid String (user ID) 10%
Contents changelog/ccontent String (text area) 65%
Figure 3 Items to prepare

Repeat container changelog

  • Initial display number 0 Set to.
  • Set "automatic increase/decrease of repeat item".Here, the increase/decrease timing is set to "before initial value setting", and the increase/decrease position is set to "add to top".
  • It does not display the add, insert, delete, move button.
Fig. 4 Setting of repeating container changelog
I am trying to store the latest change history at the top of the container.

Repeating container ID changelog/cid

Set "Output control> Style> Label width" to 5%.(The description of label width setting will be omitted hereafter.)

Date time changelog/cdate

Date and time type.

Fig. 5 Date and time type

It is read-only.

Figure 6 Make the date and time item read-only

Items of the date and time type are standard, and the sort function inside the container is enabled.I will release this.

Fig. 7 Canceling the sort function in containers by date and time items

Set the initial value at the time of registration/update by the expression as follows.

IF(CID()==FIRST(${changelog/cid}),NOW(),${changelog/cdate})

CIDIs a special function that can be used only in repeating containers and returns the position in the container.In this expression, the result of the NOW function is applied to the first line, otherwise the current value is maintained.

Figure 8 Initial Value of Date Time Item

User ID changelog/cuserid

It is read-only.

Figure 9 Make User ID Item Read Only

Set the initial value at the time of registration/update by the expression as follows.

IF(CID()==FIRST(${changelog/cid}),USERINFO("userid"),${changelog/cuserid})

In this expression, the userid of the account currently being logged on is applied to the first line, otherwise the current value is kept intact.

Figure 10 Initial Value of User ID Item

Contents changelog/ccontent

The type of input item is "text area".It is also read-only.

Figure 11 Make the content item read-only

We set the initial value of the contents by the expression as follows.

Content item (new registration)

IF (CID () ==FIRST($ {Changelog / cid}), "Data was newly registered.", $ {Changelog / ccontent})

Content item (update)

IF (CID () ==FIRST($ {Changelog / cid}), CHANGELOG (), $ {changelog / ccontent})

In this expression, the first line containsCHANGELOGApply the result of the function, otherwise keep the current value as it is.

Figure 12 Applying the CHANGELOG function to the initial value of the content item

In the above example, the repeat container "change history"leadIt was to add the latest update history to. This is a containerendWe will explain how to change it so that it will be added to.

Figure 13 Change history is added to the end of repeating containers

Change setting

Change "Automatic increase/decrease of repeat items" in Fig. 4 from "Add to top" to "Add to end".

Figure 14 Setting to add to the end

Then, change the FIRST function to the LAST function with the initial value expression.(We will change both date time, user ID and content item.)

Date Time Item

IF(CID()==LAST(${changelog/cid}),NOW(),${changelog/cdate})

User ID item

IF(CID()==LAST(${changelog/cid}),USERINFO("userid"),${changelog/cuserid})

Content item (new registration)

IF (CID () ==LAST($ {Changelog / cid}), "Data was newly registered.", $ {Changelog / ccontent})

Content item (update)

IF (CID () ==LAST($ {Changelog / cid}), CHANGELOG (), $ {changelog / ccontent})
Figure 15 Applying the CHANGELOG function to the initial value of the content item
This will store the latest change history at the end of the container.

If you are dealing with change history with multiple models, it is convenient to use it as a template model. Here is an example of making jfcDesignerUserTemplateModelitem1 in the "System" tab a "change history" template.

Figure 16 Creating a change history template

In the system tab list, you can check the change history template you created

Figure 17 Model in system tab

Application example

For any model, try selecting "template> change history" from the gear icon.

Figure 18 Add change history template items

Five items related to change history are added to the model.

Figure 19 Items Added

Lastly, we will enable the change history function of this model.

Figure 20 Enabling Change History Function
  • For repeated containers used as change history, you can prepare "maximum of only one" for one model.It is not possible to define two or more containers (for the purpose of managing change history) the same.
    Specifically, we make a judgment that only one repeating container using the CHANGELOG () function is used as the initial value expression.
  • When there is a change in the file type item, the real file name part is recorded in the change history.7.10
    Up to R7.9.2, a relative path name starting from the upload_dir folder was recorded.You can also return to this behavior.