AutoStore: AutoCapture Default Date


I recall the very first script that I ever created for a workflow with AutoStore. The scenario was for a small but very busy accounting team who needed to scan invoices, and have them delivered to a shared folder that was named Vendor Invoices in a more organized way.

In order to demonstrate how an alternative process could work, I configured an AutoCapture Form with three fields to collect the following:
  • Vendor Name
  • Invoice Number
  • Invoice Date

The Vendor Name value would be used to create the subfolder, and the file name would be comprised of the Invoice Number and Invoice Date values. The next stop was a demonstration for the client.

They were able to see a real improvement to their current process in terms of the time savings for capturing invoices, which were estimated at an average of 40 per day. Paired with the ability to easily locate the document at a later time using a well organized folder structure with consistent file naming, all of it was clear and simple.

Because most invoices would be from the previous day, I was then asked if there was a way to set the Invoice Date to yesterday's date by default.

In an instant, I recalled installing an available update on my AutoStore 4.6 server for the AutoCapture component that contained a newly added VBScript option. Not long before this moment, I had visited my local bookstore, purchased the title Microsoft WSH and VBScript Programming for the Absolute Beginner, written by Jerry Lee Ford, Jr., and remembered reading about data types, in particular, working with dates.

Indicating my high confidence to the client that this could be done, but that I would need to confirm, I returned to my AutoStore Process Designer later that day to do just that.

The first thing I did was go to the VBScript documentation found in the help file. I located a method named SetFieldValue. To use this method, the Field Name and Field Value parameters need to be supplied.

AutoCapture SetFieldValue Method
Form.SetFieldValue FieldName, FieldValue 

After several failed attempts, I realized that the Run on form load setting for the Form's configuration needed to be enabled, and was then able to see the current date value set into the Invoice Date field using the following line of code in the Form_OnLoad event handler.

Setting an AutoCapture Date field to the current date
Sub Form_OnLoad(Form)
    Form.SetFieldValue "Invoice Date", Date()
End Sub 

VBScript has a built-in function named Date() that returns the current date of the system. Next, a little subtraction to the current date, and the result becomes yesterday's date.

Setting an AutoCapture Date field to yesterday's date
Sub Form_OnLoad(Form)
    Form.SetFieldValue "Invoice Date", Date() - 1
End Sub 

This was my very first AutoStore script. It started with a problem, and with a little digging, the Invoice Date field in the Vendor Invoices AutoCapture form was set to yesterday's date.

Now, when I ran an end-to-end test, the format of the date with the slash (/) characters was something that needed to be further addressed. In the next article, I'll describe my second-ever AutoStore script where I reformat the date value to use for the file name.

Comments

Popular posts from this blog

VBScript: Ensure Backslash Folder Path

AutoStore: Create a Custom RRT

AutoStore: Workflow Loop Example