Subject: RE: Another approach
I was able to create a dynamic view (not using a profile doc)… but the result was the same.
The problem I had was it updates the same view on the server, but it is a performance hit, and only one person can run it at a time (use doc locks…). But it will work all day, every day on a local replica…since there isn’t a performance hit…
I used a form for the user to select the choices from, the select statement was created from that and set to the view when closed, and refresh the view.
it took some dancing but I got it…
Sub Click(Source As Button)
Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim view As NotesView
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim viewName As String
Dim formula As String
Dim f_name (1 To 6) As String
f_name(1) = "xDays_Funnel"
f_name(2) = "xDays_qPending"
f_name(3) = "xDays_Back"
f_name(4) = "xDays_From"
f_name(5) = "xDays_To"
f_name(6) = "xSalesSource"
Set db = s.CurrentDatabase
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
p_Status = uidoc.FieldGetText( "xDays_Funnel")
p_Quote = uidoc.FieldGetText( "xDays_qPending")
p_Source = uidoc.FieldGetText( "xSalesSource")
p_Days = uidoc.FieldGetText ("xDays_Back")
p_From = uidoc.FieldGetText ("xDays_From")
p_To = uidoc.FieldGetText ("xDays_To")
If p_Status <> "" Then
array_Status = STRExplode ( p_Status, ";", 0)
funnelStatus = MakeString(array_Status)
array_Status = ""
End If
If p_Quote <> "" Then
array_Quote = STRExplode ( p_Quote, ";", 0)
quoteStatus = MakeString( array_Quote)
array_Quote = ""
End If
If p_Source <> "" Then
array_Quote = STRExplode ( p_Source, ";", 0)
quoteSource = MakeString ( array_Quote )
array_Quote = ""
End If
If funnelStatus = "" Then
funnelString = ""
Else
funnelString= " & ( status = " & funnelStatus & " )"
End If
If quoteStatus = "" Then
quoteString = ""
Else
quoteString = " & ( q_Pending = " & quoteStatus & " )"
End If
If quoteSource = "" Then
sourceString = ""
Else
sourceString = " & ( oppSource = " & quoteSource & ")"
End If
If p_Days = "" Then
daysString = ""
Else
daysString = " & (RecieptDate > [" & (Date - p_Days ) & "])"
End If
If p_From = "" Then
dateString = ""
Else
dateString = " & (RecieptDate > [" & p_From & "] & RecieptDate < [" & p_To &" ] )"
End If
buildString = |(Form = "SalesBid")|
buildString = buildString & funnelString
buildString = buildString & quoteString
buildString = buildString & sourceString
buildString = buildString & daysString
buildString = buildString & dateString
finalString = Trim(buildString)
t_formname = finalString
formula = "SELECT (" & t_formname & ")"
’ Let’s clean up our variables
finalString = ""
buildString = ""
funnelStatus = ""
quoteStatus = ""
funnelString = ""
quoteString = ""
daysString = ""
dateString = ""
t_formname = ""
p_Status = ""
p_Quote = ""
p_Days = ""
p_From = ""
p_To = ""
Set db = s.CurrentDatabase
Set view = db.getView( "rViews" )
view.SelectionFormula = formula
Call view.Refresh
’ Let’s clear all the field values so there is no mistakes on the next query
’ Forall x In f_name()
’ Call uidoc.FieldClear( x )
’ End Forall
End Sub
makestring function:
If Not Isarray(workList) Then
Goto done
End If
loopcount% = 1
statusCount = Ubound(workList)
Forall x In workList
If statusCount = 0 Then
sPrompt = | "| & x & |" |
Else
If loopcount% <> 1 Then
sPrompt = sPrompt & |: "| & x & |" |
Else
sPrompt = | "| & x & |" |
End If
loopcount% = loopcount% + 1
End If
End Forall
MakeString = sPrompt
done:
STRExplode function:
Function STRExplode( Byval strValue As String, strDelimiter As String, bBlanks As Variant) As Variant
'** This function takes a string and converts it to an array, based on a delimiter
'** Parameters:
'**strValue- the string to explode
'**strDelimiter- the delimiter
'**bBlanks- a boolean value, pass true to have blanks placed in array when two delimiters have nothing between them
'**pass false to ignore the blanks
Dim strTemp As String
Dim strValues() As String
Dim iPlace As Integer
Dim idelimLen As Integer
Dim iValueCount As Integer
idelimLen = Len( strDelimiter)
iPlace = Instr( strValue, strDelimiter)
Do While iPlace <> 0
If (iPlace <> 1 Or bBlanks) Then
Redim Preserve strValues(iValueCount) As String
strValues(iValueCount) = Left( strValue, iPlace - 1)
iValueCount = iValueCount + 1
End If
strValue = Right( strValue, Len( strValue) - iPlace - idelimLen + 1)
iPlace = Instr( strValue, strDelimiter)
Loop
If Len( strValue ) <> 0 Or bBlanks Then
Redim Preserve strValues(iValueCount) As String
strValues(iValueCount) = strValue
Elseif iValueCount = 0 Then
Redim Preserve strValues(iValueCount) As String
End If
STRExplode = strValues
End Function
(Makestring and StrExplode functions i found on the web and adapted to this project).
This code is in a updateview button on my selection form, then the user close the form.
I called the form from a action button in a view (rView) and when the view opened or closed it set and deleted locks if the script was being run by someone else on the server.
I hope this make sense…