|
|
|
|
|
|
|
|
Managing expenses with Palm and Notes (continued)
Note that there are a couple of lines at the top of the form reminding me to print it in Landscape; these have a hide-when to stop them from being printed along with the form.
Making a claim On the Expenses view, the Make a Claim button calls an agent that then runs Lotuscript code in a script library. Unipart requires that each expense claim be made in only one currency, so the items to be claimed are selected from the view, and the agent is started. I have no validation code on this selection apart from checking that no more than twelve items have been selected. It's easier to use the Unmake claim action and try again than to check all the items are in the same currency before the agent processes them.
You can view the entire agent code at http://www.component-net.com/pp-extras/pp042001-expenses.html. Before you refer to the code, though, I'm going to call out some features of it.
The agent code First, the subs CurrName and ClaimType turn the Palm code values into text strings. Sub CurrRate looks up exchange rate values, not to use in calculations, but merely to add to the form. You can see how those work. The guts of the code is in the sub MakeClaim. Here I've line-numbered the code to make it easier to refer to.
At line 6 we read the profile document and then create a new claim document. At line 9 we call sub ProfFields to add the static stuff from the profile to the claim form and to zero-ize the totals fields. You'll note in ProfFields, lines 8-13, we set some form fields to "4." Actually, the field on the form uses the Monotype Sorts font, so the character 4 prints as a check mark. Line 11 gets a handle on the selected items to be processed, and we then check how many there are. In line 18, we get a subject line for the claim form itself, and this is the only place where I type anything in the whole process of creating a claim.
From lines 20-55, there's a processing loop, one execution per input document. However, the lines on the form are not an array, so we use a bit of trickery illustrated in lines 23-25 to be able to treat these lines as an array. Remember that I said I'd let the designer name the fields on the claim form as I pasted them in? Well this is why: I was able to make the field names in each column of the form have a numeric suffix, for example, R1_Date_0 through R1_Rate_11.
Line 23 gives me a counter that counts up from zero. Line 24 gives me the string value of this, prefixed with an underscore: _0 through _11. Line 25 then uses the Execute Lotuscript function to, in effect, create the line of code on the fly with string concatenation and then execute it. So, as I go around the loop, the line of code at line 25 is re-created each time:
ClaimDoc.R1Date_0 = ExpDoc.Date(0)
ClaimDoc.R1Date_1 = ExpDoc.Date(0)
|
And so on. You can see this trick in several other places in the code.
Line 26 then puts the expense type (Taxi, Hotel, etc.) onto the claim and adds on the contents of the vendor field. Remember, I said I used this to enter details of the specific expense, such as where I parked my car or why I used a taxi.
|
|
|
|
|
|
|
|
|
|
|