RESOLVED: Dynamic View from Checkbox

Hi Ladies and Gents,

as usual: I’m fairly new to Lotus Notes/Domino

I’m trying to set up a dynamic view (shared)

The view has some actionbuttons, which I designed as Checkboxes.

The checkboxes control themselves via a profile document (Set/GetProfileField)

The view shows max three different forms

A) Document

B) Discussion

C) Info

The Checkboxes are setting ProfileFields

Document=X/O

Disussion=X/O

Info=X/O

I want to use the view selection statment that way

SELECT form = @if(a = “X”;“Document”;“”) | form = @if(b = “X”; “Discussion”;“”) | form = @if(c=“X”;“Info”;“”)

Using GetProfileField in the SELECT statement seems not to work

Trying this:

a=“X”;

b=“X”;

c=“X”;

SELECT form = @if(a = “X”;“Document”;“”) | form = @if(b = “X”; “Discussion”;“”) | form = @if(c=“X”;“Info”;“”)

shows the proper documents as selected via the variables

(or hides them vice versa)

But:

a=@GetProfileField(“ProfileDok”;“Document”);

b=@GetProfileField(“ProfileDok”;“Discussion”);

c=@GetProfileField(“ProfileDok”;“Info”);

SELECT form = @if(a = “X”;“Document”;“”) | form = @if(b = “X”; “Discussion”;“”) | form = @if(c=“X”;“Info”;“”)

doesn’t work.

by the way :

@command([RefreshForm]) at the end of the code for the checkboxes seems to have no influence

Any comment is very appreciated.

Thx a lot

Martin

Subject: Another approach

Is to have the number of required views, and as each option is selected switch to the relevant view;
You’d have the view as an embedded view and refresh on keyword change.

So in your case you have six possible selection options, so you’d need six views

View1

View2

View3

View4

View5

View6

Document

X

X

X

O

O

O

Discussion

X

X

O

O

O

X

Info

X

O

O

O

X

X

Then each view would have a different selection formula

Example:

View1

SELECT form = “Document”:“Discussion”:“Info”

View2

SELECT form = “Document”:“Discussion”

View3

SELECT form = “Document”

etc. etc.

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…

Subject: Dynamic View from Checkbox

There is no such thing as a dynamic shared view in an NSF. You can, however, categorize a view (that is, make the first column of the view sorted categorized) and display a subset of the view as a single-category embedded view or by using the @SetViewInfo function.