AutoStore: Processing Date Values
Simply put, dates represent fundamental pieces of document metadata. In this article, we'll look at processing date values with the VB/JScript process component in AutoStore. To illustrate why this can be useful, consider the following scenario.
A document needs to be routed to a folder. One of the folders in the destination path is characterized by the year. In the capture form, an entire date value is collected, but only its year is needed for that subfolder. Would we ask the user to input only the year separately?
Of course, why should we? We already have the desired date. The year would just needs to be extracted. Perhaps we already have a mechanism to get what we need. To know for sure, it's important to understand what that date actually represents. For example:
Once we know the target date, reformatting or extracting certain portions is the next stop.
Parts of this entire script could also be used as a template, or further personalized for any custom date/time format combinations.
The short answer is we don't have to. Now, if the VB/JScript process component already being used in the CFG for other processes, then we won't need to add another component. It is another available option, and it comes down to preference.
A document needs to be routed to a folder. One of the folders in the destination path is characterized by the year. In the capture form, an entire date value is collected, but only its year is needed for that subfolder. Would we ask the user to input only the year separately?
Of course, why should we? We already have the desired date. The year would just needs to be extracted. Perhaps we already have a mechanism to get what we need. To know for sure, it's important to understand what that date actually represents. For example:
Capture Date
Many AutoStore components offer valuable date parts in the Available RRTs list. Their respective values reflect the current date or time. However, not all components provide these RRTs, which oddly enough, also includes the AutoCapture capture component.
Document Date
Not every document processed by AutoStore is done so on the date of the document itself. As such, if an invoice dated for yesterday is actually captured today, then the true document date, also referred to by some as the transaction date, would be needed.
Activity Date
Documents that describe some type of event usually contain a date that indicates when that event was started or completed. It could be when a widget was replaced, the month something was billed, or the date that travel for an employee had taken place.
Many AutoStore components offer valuable date parts in the Available RRTs list. Their respective values reflect the current date or time. However, not all components provide these RRTs, which oddly enough, also includes the AutoCapture capture component.
Document Date
Not every document processed by AutoStore is done so on the date of the document itself. As such, if an invoice dated for yesterday is actually captured today, then the true document date, also referred to by some as the transaction date, would be needed.
Activity Date
Documents that describe some type of event usually contain a date that indicates when that event was started or completed. It could be when a widget was replaced, the month something was billed, or the date that travel for an employee had taken place.
Once we know the target date, reformatting or extracting certain portions is the next stop.
Sample Script
Depending on the particular goal, a date may simply need to be reformatted, or parts of the date used in the workflow. With that, below is an entire process script that will take a date, and produce custom RRTs for different date parts.
AutoStore_DateProvider.vbs
'================================================================================
' SETUP DESCRIPTION
'--------------------------------------------------------------------------------
' To use this script in AutoStore, add the following VB/JScript Field:
' - Field: p_InputDate
' - Value: Add the date RRT to evaluate
'================================================================================
' RRT DESCRIPTION
'--------------------------------------------------------------------------------
' The following RRTs are created
' DATE RRTs ...
' ~USR::%Y4%~ (Year 4-digit)
' ~USR::%Y2%~ (Year 2-digit)
' ~USR::%MM%~ (Month)
' ~USR::%M2%~ (Month 2-digit)
' ~USR::%MA%~ (Month Abbreviated Name)
' ~USR::%MF%~ (Month Full Name)
' ~USR::%DD%~ (Day of Month)
' ~USR::%D2%~ (Day of Month 2-digit)
' ~USR::%DA%~ (Day Abbreviated Name)
' ~USR::%DF%~ (Day Full Name)
' ~USR::%DW%~ (Day of Week Number)
' ~USR::%WW%~ (Week of Year Number)
' TIME RRTs ...
' ~USR::%HH%~ (Hour)
' ~USR::%H2%~ (Hour 2-digit)
' ~USR::%NN%~ (Minute)
' ~USR::%N2%~ (Minute 2 digit)
' ~USR::%SS%~ (Second)
' ~USR::%S2%~ (Second 2-digit)
' ~USR::%LL%~ (Locales, AM/PM)
' COMBINED RRTs ...
' ~USR::%Y4M2D2%~ (Y4M2D2)
' ~USR::%H2N2S2%~ (H2N2S2)
'================================================================================
' EVENT PROCEDURES
'--------------------------------------------------------------------------------
Sub DateProvider_OnLoad
EKOManager.StatusMessage("DateProvider_OnLoad Starting ...")
EKOManager.StatusMessage(" p_InputDate=" & p_InputDate)
' Get the date-part values ...
Dim sY4 : sY4 = GetDateY4(p_InputDate)
Dim sY2 : sY2 = GetDateY2(p_InputDate)
Dim sMM : sMM = GetDateMM(p_InputDate)
Dim sM2 : sM2 = GetDateM2(p_InputDate)
Dim sMA : sMA = GetDateMA(p_InputDate)
Dim sMF : sMF = GetDateMF(p_InputDate)
Dim sDD : sDD = GetDateDD(p_InputDate)
Dim sD2 : sD2 = GetDateD2(p_InputDate)
Dim sDA : sDA = GetDateDA(p_InputDate)
Dim sDF : sDF = GetDateDF(p_InputDate)
Dim sWD : sWD = GetDateWD(p_InputDate)
Dim sWW : sWW = GetDateWW(p_InputDate)
' Get the time-part values ...
Dim sHH : sHH = GetTimeHH(p_InputDate)
Dim sH2 : sH2 = GetTimeH2(p_InputDate)
Dim sNN : sNN = GetTimeNN(p_InputDate)
Dim sN2 : sN2 = GetTimeN2(p_InputDate)
Dim sSS : sSS = GetTimeSS(p_InputDate)
Dim sS2 : sS2 = GetTimeS2(p_InputDate)
Dim sLL : sLL = GetTimeLL(p_InputDate)
' Combined values ...
Dim sY4M2D2 : sY4M2D2 = = sY4 & sM2 & sD2
Dim sH2N2S2 : sH2N2S2 = = sH2 & sN2 & sS2
' Create RRTs ...
Set pTopic = KnowledgeContent.GetTopicInterface
If Not (pTopic Is Nothing) Then
' DATE RRTs ...
pTopic.Replace "~USR::%Y4%~", sY4
pTopic.Replace "~USR::%Y2%~", sY2
pTopic.Replace "~USR::%MM%~", sMM
pTopic.Replace "~USR::%M2%~", sM2
pTopic.Replace "~USR::%MA%~", sMA
pTopic.Replace "~USR::%MF%~", sMF
pTopic.Replace "~USR::%DD%~", sDD
pTopic.Replace "~USR::%D2%~", sD2
pTopic.Replace "~USR::%DA%~", sDA
pTopic.Replace "~USR::%DF%~", sDF
pTopic.Replace "~USR::%WD%~", sWD
pTopic.Replace "~USR::%WW%~", sWW
' TIME RRTs ...
pTopic.Replace "~USR::%HH%~", sHH
pTopic.Replace "~USR::%H2%~", sH2
pTopic.Replace "~USR::%NN%~", sNN
pTopic.Replace "~USR::%N2%~", sN2
pTopic.Replace "~USR::%SS%~", sSS
pTopic.Replace "~USR::%S2%~", sS2
pTopic.Replace "~USR::%LL%~", sLL
' COMBINED RRTs ...
pTopic.Replace "~USR::%Y4M2D2%~", sY4M2D2
pTopic.Replace "~USR::%H2N2S2%~", sH2N2S2
Else
' Do nothing
End If
Set pTopic = Nothing
EKOManager.StatusMessage("DateProvider_OnLoad Finished.")
End Sub
Sub DateProvider_OnUnload
End Sub
'================================================================================
' DATE-TIME HELPER FUNCTIONS
'--------------------------------------------------------------------------------
' DATE PARTS ...
' Return numeric 4-digit year as an integer
Function GetDateY4(DateExpression)
GetDateY4 = DatePart("yyyy", DateExpression)
End Function
' Return 2-digit year as a string
Function GetDateY2(DateExpression)
GetDateY2 = Right("0" & DatePart("yyyy", DateExpression), 2)
End Function
' Return numeric month as an integer
Function GetDateMM(DateExpression)
GetDateMM = DatePart("m", DateExpression)
End Function
' Return padded 2-digit month as a string
Function GetDateM2(DateExpression)
GetDateM2 = Right("0" & DatePart("m", DateExpression), 2)
End Function
' Return abreviated month name as a string
Function GetDateMA(DateExpression)
GetDateMA = MonthName(DatePart("m", DateExpression), True)
End Function
' Return full month name as a string
Function GetDateMF(DateExpression)
GetDateMF = MonthName(DatePart("m", DateExpression))
End Function
' Return numeric day as an integer
Function GetDateDD(DateExpression)
GetDateDD = DatePart("d", DateExpression)
End Function
' Return padded 2-digit day as a string
Function GetDateD2(DateExpression)
GetDateD2 = Right("0" & DatePart("d", DateExpression), 2)
End Function
' Return abreviated weekday name as a string
Function GetDateDA(DateExpression)
GetDateDA = WeekdayName(Weekday(DateExpression), True)
End Function
' Return full weekday name as a string
Function GetDateDF(DateExpression)
GetDateDF = WeekdayName(Weekday(DateExpression))
End Function
' Return numeric day of week as an integer
Function GetDateDW(DateExpression)
GetDateDW = DatePart("w", DateExpression)
End Function
' Return numeric week of year as an integer
Function GetDateWW(DateExpression)
GetDateWW = DatePart("ww", DateExpression)
End Function
' TIME PARTS ...
' Return numeric hour as an integer
Function GetTimeHH(DateExpression)
GetTimeHH = DatePart("h", DateExpression)
End Function
' Return padded 2-digit hour as a string
Function GetTimeH2(DateExpression)
GetTimeH2 = Right("0" & DatePart("h", DateExpression), 2)
End Function
' Return numeric minute as an integer
Function GetTimeNN(DateExpression)
GetTimeNN = DatePart("n", DateExpression)
End Function
' Return padded 2-digit minute as a string
Function GetTimeN2(DateExpression)
GetTimeN2 = Right("0" & DatePart("n", DateExpression), 2)
End Function
' Return numeric second as an integer
Function GetTimeSS(DateExpression)
GetTimeSS = DatePart("s", DateExpression)
End Function
' Return padded 2-digit second as a string
Function GetTimeS2(DateExpression)
GetTimeS2 = Right("0" & DatePart("s", DateExpression), 2)
End Function
' Return Locales "AM" or "PM" as a string
Function GetTimeLL(DateExpression)
Dim iHr : iHr = DatePart("h", DateExpression)
If iHr >= 12 Then
GetTimeLL = "PM"
Else
GetTimeLL = "AM"
End If
End Function
Parts of this entire script could also be used as a template, or further personalized for any custom date/time format combinations.
Final Thought
The Data Filter can evaluate and reformat dates. So, why use a script?The short answer is we don't have to. Now, if the VB/JScript process component already being used in the CFG for other processes, then we won't need to add another component. It is another available option, and it comes down to preference.
Comments
Post a Comment