Tutorial 5 - Record events in a file

This tutorial will implement a JSS process trigger that automatically writes the type of event which happens with files and folders into a .txt file (file in local).

Steps

  1. Open CompleteFTP Manager and select the Events tab. In the Process Triggers panel, click on the 'Add' button to add a new event.

  2. Choose multiple events or all events.

  3. Check the "Trigger on success" box, then choose the JSS script and enter the script shown below:

    var file = system.getFile("/Temp/JSSScript_Result.txt");
    file.appendText(new Date() + "\n"
    + event.type + "\n"
    + event.fileName  + "\n"
    + "\n");
    

    This script will open the file or create the file (if it doesn't exist) then it will append the time stamp, the type of event, and the file name.

    The process trigger should now look like this:

  4. When you've done scripting, click on 'Apply Changes' to save and start using this event.

Testing your process trigger

Now your new JSS process trigger is ready to use. Let's check it using Filezilla. If you're new to Filezilla, please check the 'how to use Filezilla' guide here.

Before testing this process trigger, you have to create a Windows folder which maps to C:\Temp.

  1. Open Filezilla and connect to the server as 'user1'.

  2. Upload a file ('test-image1.jpg') to the server, rename it (to 'test-image2.jpg') then download it from server.

  3. Now check in C:\Temp to see if the JSSScript_Result.txt file has been created and that it has written the content as shown below: