Support > Repository > CSV/Excel input/output > Call up the script on upload update
ja | en

You can call the script at the timing of upload update processing. R7.9

Choose "Upload update" from "Screen> Script> Controller> Screen". In "Execution timing", select "After upload update (every one)".

Figure 1 Writing a script

For details on how to write scripts, see "Business logicPlease read.

When the script is called

The script created here will be invoked after registration or update succeeds with upload update.

Allow script to be written at the time of deletion

By default the script is invoked during registration or update.
In order to be called even when deleting, please enable "Handling deletion with screen> Upload> Upload update setting> script".

Figure 2 Allow script to be written when deleting
When this setting is enabled, values ​​will be read once from the database before deleting.Pass the read values ​​to the script.Therefore, the performance of the deletion process is affected.(A procedure called database reading occurs every time the deletion processing is done.)

Objects available in script

The following objects are available in the script.

UPLOADACTION

The current process indicates registration, update, or deletion.

value Description
insert Indicates that the data was newly registered.
update Indicates that the data has been updated.
delete Indicates that the data has been deleted.

specification

  • The same script is called for both registration, update and deletion.By looking at the value of UPLOADACTION, you can know which operation is done.
  • If the operation fails, this script will not be called.For example, a database exception occurred due to a unique constraint, and an update failed.
  • You can not change the value of a model in a script.(Changing it will be ignored.This is because scripts are called "after" of registration and update processing.

Assume that the upload target data contains a mail address.Here is an example of sending a mail to that mail address when the upload update succeeds.

var replaceMap = new java.util.HashMap();
replaceMap.put("$${{customer_p.mailaddress}}", customer_p.mailaddress.content);
var mailman = p.appctx.getBean("MailMessageManager");
mailman.send("customer_upload", replaceMap, errorManager, "SendmailAtUploadCustomer ", p);

When inputting using the editor that is provided as a standard in Designer, please describe the key part of replaceMap on the second line as $$ {{...}}.In the actual output file "UploadUpdate Model ID_AfterUpdate.js", it is $ {...}.

Also in the second line, since the value part of replaceMap uses items of the presentation model, please give ". Content" to get the value part.

You can write a script that calls "once" at the beginning and end of the upload update process.

Figure 3 Scripts to be called at startup and shutdown
A script called UploadUpdate <model ID> _processStart.js and UploadUpdate <model ID> _processEnd.js is generated respectively.