Hello World Automation

Automations are most frequently scheduled applications that are triggered by Timers. However, Linx also comes with a number of event-based triggers, like DirectoryWatchers or MessageQueue listeners that can trigger a Linx application.

Building a scheduled automation

  1. Open the Linx Designer and click Create Solution
  2. Open the Utilities plugin in the plugins panel on the right side of the designer, find the Timer service (services have a purple SVC prefix) and drag it into the Solution Explorer in the top left your the Designer
  3. Linx will open the TimerEvent in as a tab in the central working area. This is where you will create the logic that executes when the Timer service fires
  4. Select the Timer service in the Solution Explorer and locate the Run every property in the properties panel in the bottom left of the designer
  5. To make the Timer service run its TimerEvent every 3 seconds, change the value to 00:00:03
  6. In the plugins panel on the right of the Designer, locate an item called String (it has a green STR prefix) inside of the Linx plugin and drag it into the tab called TimerEvent
  7. In the properties panel in the bottom left of the designer, locate the property called Name and change the value from String to MyString
  8. Locate a property called Value and enter Hello World
  9. Select the Add plugins button in the plugins panel on the right of the designer to open the plugins popup
  10. Locate the File plugin and select ADD to add it to your solution (the initial download might take a moment) and close the popup
  11. Open the File plugin in the plugins panel and locate the TextFileWrite function (it has a blue FNC prefix)
  12. Drag the TextFileWrite function into the TimerEvent tab in the center of the designer
  13. Select the TextFileWrite function in the TimerEvent tab and locate the File path property
  14. Enter the path to a text file, such as c:\temp\file.txt (the file does not have to exist)
  15. Locate the Contents property, open the dropdown, select MyString and add + "\n" so the property value becomes =MyString + "\n" (\n writes a new line character)
  16. Right-click on the Timer service in the Solution Explorer and select an item called Debug to place the Designer into Debug mode
  17. In the Debug Output panel at the bottom of the Designer, wait for a message that says Ready to debug. Click START to start debugging. When you see it, click the Start button in the top left of the Designer
  18. Every 3 seconds the Timer service fires its event handler (called TimerEvent) which runs the logic it contains. The Debug Output panel then shows Timer Service fired. When you see a few of these messages you can open the file and see the result of your automation

All steps in a video

Explanation

When you start the timer service, it fires the TimerEvent event handler every 3 seconds
The TimerEvent instantiates a String and assigns a value to it
When the TextFileWrite function is called it creates or finds the file in its path property
TextFileWrite writes then the ouput of the variable MyString to the file

Challenge

If you had fun building this solution in Linx, why not extend it a bit further? Instead of returning a static string

  • change the value of MyString and debug the service again
  • in the dropdown of the Contents property of the TextFileRead, select the Expression Editor and use this expression "The time is " + $.System.CurrentDateTime as the property value
  • use the CallRESTService function from the REST plugin to call another REST service and assign the ResponseBody property to the contents property of the TextFileRead
  • use the ExecuteSQL function from the Database plugin to select some data from a database and assign it to the contents property