Thursday, January 28, 2010

Getting the Alpha Five Append Operation to work in web environment

One of the neat things about Alpha Five is mixing the Genie type tools on the 'desktop side' to build completed operations that you can then run from the web. Without these Genies, you would have to write the code from scratch yourself. Most of the Operations transfer over with little work. The Append Operation however takes a bit of modification. Here are instructions on how to take an Append Operation from the desktop to the web.

Click on any image for a larger view.
The process starts out by using the Genie to create an Append Operation.

Then click the "XB" icon to get the underlying code, shown below.

You simply copy-paste this to an A5W page to transfer this operation to the web.

This screen shows the code after pasting in an A5W page, but with required edits as described below:

  • Line 3-6 Optional, this is the code to purge all records from the target table. You may or may not want to do this.
  • Line 9 Changed code to use the function.
  • Line 10 Replaced the hard-coded path with the Alias, in my case [PathAlias.ADB_Path]. See an important note about this on the last image.
  • Line 11 Optional, this is debug code to write my path result, I use this method often to see my parameters.
  • Line 19 (and 21, 23, 25). Note that I removed the string "@hitsandprofiles->" from each line.These are relevant in Desktop, not in the web.

Finally, there is an important setting on the Web Publishing Panel at View | Settings | Preferences | Web Publishing that determines if your Alias (e.g.: [PathAlias.ADB_Path]) will get resolved when the files are Published or at Run Time (when someone runs your web page). If you resolve Alias at Publish Time, no need to follow these instructions. But if you resolve Alias at Run Time you MUST take these instructions in to account. In the image, line 14 uses the Alias, but line 15 uses a variable that was set using the expression:

path = filename_decode("[PathAlias.ADB_Path]")

The reason is that the function knows how to resolve the Alias, but the same is not true for the expression on line 15. There you must resolve the Alias before using it.

No comments: