Passing values help

Hi,

I’m trying to design an agent that will append values to a field depending on what users choose from a dialog box.

The first part of the agent will prompt users with a dialog box from a static form that I have created. The values in that form will not change.

Depending on whether they choose a certain value from the dialog box, a 2nd dialog box will appear. I would like the values in this dialog box to be dynamic, depending on what values are already present in the underlying form. Eg, if the values in the ‘Liaison Branches’ field in the underlying doc contain ‘A’, ‘B’ and ‘C’, I would like the dialog box to show these values and prompt the user which one to tick, which will then update another field on the document. Hope this makes sense, I have some sample code below.

When I’m looping through the ‘Liaison branches’ in ‘doc’, I’m able to messagebox back the values, but not append these to the ‘tempdoc’ I’ve created (it comes up with an error). Hope someone can help!

Sub Initialize

Dim s As New NotesSession

Dim db As NotesDatabase

Dim docCollection As NotesDocumentCollection

Dim doc As NotesDocument 

Dim ws As New NotesUiWorkSpace

Dim tempdoc As NotesDocument

Dim tempdoc2 As Notesdocument

Dim item As NotesItem

Dim nam As NotesName

Dim CommonName As String

Dim item2 As NotesItem



Set db = s.CurrentDatabase

Set docCollection = db.UnprocessedDocuments

Set doc = docCollection.GetFirstDocument 

Set tempdoc = db.CreateDocument

Set item = doc.GetFirstItem( "Approvals" )

Set nam = New NotesName(doc.GetItemValue("LeadBriefingOfficer")(0))

Set tempdoc2 = db.CreateDocument

CommonName = nam.Common

tempdoc.form = "CheckboxRetickDialog"	

tempdoc2.form = "LiaisonBranchList"

Set item2 = tempdoc2.GetFirstItem( "BranchList" )



Call ws.Dialogbox("CheckboxRetickDialog", True,True, False, False, False, False, "Select the checkbox to retick", tempdoc)



Forall values3 In doc.LiaisonBranches		

	Messagebox values3	

	Call item2.AppendToTextList(values3)

End Forall



Forall values In tempdoc.SubmissionSelection

	Select Case values		

’ Case “Liaison Branch”

’ Call ws.Dialogbox(“LiaisonBranchList”, True,True, False, False, False, False, “Select Liaison Branch”, tempdoc2)

’ Call ws.Dialogbox(“tempdoc2”, True,True, False, False, False, False, “Select Liaison Branch”, tempdoc2)

’ Forall liaisons In tempdoc2.BranchList

’ Call item.AppendToTextList("Liaison Branch: " + liaisons)

’ Call Doc.Save(False, True)

’ End Forall

	Case "Lead Branch"

		Call Item.AppendToTextList("Lead Branch: " + doc.LeadBranch(0))

		Call Doc.Save(False, True)

	Case "Deputy Secretary"

		Call item.AppendToTextList("Deputy Secretary")

		Call Doc.Save(False, True)

	Case "Author"

		Call item.AppendToTextList("Author: " + CommonName)

		Call Doc.Save(False, True)

	End Select

End Forall	

End Sub

Subject: Passing values help

There’s no need to set the form on the temporary documents – the call to DialogBox determines which form to use anyway. On the form for your second dialog, create a hidden multivalue text field at the top of the form (outside of the table – and yes, it DOES matter whether or not the field is hidden, since it can shift the dialog in its window if it isn’t) and put the value list there. Make that field’s name the choices formula for the checkbox, radio or combobox that you want the user to select from. Since the document in the dialog is not being saved, the extra field won’t matter.

Subject: RE: Passing values help

Hi Stan,

Thanks for replying so quickly.

I have created a field on the form for my 2nd dialog (LiaisonBranchList). I have hidden the field by ticking the boxes under 'Hide Paragraph when Document is’on the ‘Paragraph Hide When’ tab in the field properties box under Is this the ‘proper’ way to hide a field?

I wasn’t sure what you meant by ‘put the value list there’ for the hidden field. Do you mean in the ‘Default Value’ for the hidden field I put something like doc.LiaisonBranches?

Also, do I select ‘Use Formula for Choices’ and then add in FIELD:= ‘HiddenField’ for the choices list?

Thanks in advance

Subject: RE: Passing values help

You said you wanted the user to choose between a number of values, right? You put those values into the mutlivalue hidden field. In the selection field, select “Use formula for choices”, then just enter the name of the hidden field as the formula – no other code. The user can then use the selection field to choose among the values you put into the hidden field.

Subject: RE: Passing values help

Hi Stan,

I don’t think I’ve explained it properly…

The values that the user will choose from in the 2nd dialog box will be dynamic. Ie, if they run the agent on one document, doc.LiaisonBranches may be ‘A’, ‘B’ and ‘C’. If they run the agent on another document, doc.Liaison Branches might be ‘D’, ‘E’ and ‘F’.

so basically the first dialog box will be static, and 2nd dialog box I want to present to the users the values that are in doc.LIaisonBranches (ie, it will differ from document to document).

Hope this makes more sense.

Subject: RE: Passing values help

Yes, I understood, and if you’d just try what I suggested, you’d see that it works exactly the way you want.

Subject: RE: Passing values help

Also, just wanted to re-iterate that the choices in the 2nd dialog box should ONLY show what’s in the Liaison Branches field for the doc. I have been able to create a 2nd dialog box and just have static entries in the underlying form/listbox, but that presents the user with ALL the possible values and asks them to select ONLY the ones that apply to that doc, whereas I want the user to see ONLY what’s relevant to that doc.

Subject: RE: Passing values help

HI Stan,

Apologies for the misunderstanding/s, bit of a newbie to Notes design…

anyway, I’ve created a hidden field on my 2nd dialog box form (LiaisonBranchList) called ‘HiddenField’. In the Default Value for ‘HiddenField’, I have listed each of the values that COULD theoretically be chosen from the 2nd dialog box. I have seperated them by semi-colon (The Default Value for the field is ‘Formula’, which I’m unable to change as the box is grayed out.) Eg:

A;

B;

C;

D;

E;

F;

I have created a ListBox in another field on the document called ‘BranchList’. In the choices I have entered ‘HiddenField’.

If I select a document that has some of those values in its ‘LiaisonBranches’ field, run the Agent and select ‘Liaison Branch’, it does present a 2nd dialog box, but there are no entries in it to select from.

Once again, I do appreciate all the help, so thanks for taking the time to reply.

Subject: RE: Passing values help

Hi Stan,

I have gotten a little further with your suggestions, but it still isn’t quite working how i’d hoped. In the default values of the ‘HiddenField’ field, I have the following values:

“BST”:“Government”:“Legal”

On the document I’m trying to run the agent on, the LiaisonBranches field only has one ‘branch’ liaising, that is ‘BST’. When I run the agent, it brings up the 2nd dialog box, but with all the values to choose from (Eg, BST, Government and Legal) - I only want ‘BST’ to show in the 2nd dialog box.

Jason