Getting Customized User Input

I have an application where users populate a checklist made up of random questions and send the checklist for review. Each question can be pass or fail, and if the result is fail, the user has to include more information in a “comments” field for each question. I need to create a customized sequence of prompts that appear when the reviewer clicks on the “Review” button, which basically summarizes the failed questions, lists the comments for each one, and requires the reviewer to indicate if the comment is adequate (Approved) or not (Rejected). If not, the reviewer must enter a comment as to why.

Once all failed questions are reviewed and reviewer comments entered, the review section of the form is automatically populated with either:

a) the reviewer’s name and date, or

b) the reviewer’s comments for each rejected question

How can I design a dialogbox to loop through all the failed questions which would include:

  1. The original failed question

  2. The original user comment

  3. An Approve or Reject button

  4. A comment field for the reviewer to enter additional information to be sent to the user

This dialogbox would have to appear once for each question, or could include a listing of all failed questions, comments and multiple sections for approval or rejection and comments for each reviewer response. How do you write this information back to the original document if the dialogbox doea not share any fields with the original document?

I’ve never used dialogbox with script, so I’m looking for pointers…thanks!

Subject: Getting Customized User Input

Here is a sample of calling a dialog that holds the follwoing fields:Server

Database

Sub SelectTargetDB

’ required element: form: GetTargetDB

Dim ws As New NotesUIWorkspace

Dim db As NotesDatabase

Dim dlgdoc As NotesDocument

Dim targetdb As New NotesDatabase(“”, “”)

Set ws = New NotesUIWorkspace

Set db = ws.CurrentDatabase.Database

Set dlgdoc = New NotesDocument(db)

Call ws.DialogBox(“GetTargetDB”, True, True, False, False, False, False, “Select a database”, dlgdoc)

If dlgdoc.Database(0) <> “” Then

If targetdb.Open(dlgdoc.Server(0), dlgdoc.Database(0)) Then

Else

Msgbox "Cannot open the target database " + dlgdoc.Database(0) + " on " + dlgdoc.DispServer(0), 16, “Error”

End If

Else

Msgbox “You did not select a target database”, 16, “Warning”

End If

End Sub

HTH

Subject: Getting Customized User Input

The user self test system I designed puts one question per document. We create a master question set for any test, then provide the training coordinator with a method to spawn user tests on demand. The master contains both the question and answer, the user tests do not include the answer (no way for the user to use the property box to find the answer that way)

The user answers one question per doc, with pass/fail per question. We don’t have a need for specific administrator/supervisor responses to each missed question, but in a ‘one doc/one question’ design, this becomes trivial.

This system has the advantage of providing an easy way to create tests of any length.

There’s more to it than this, but this gives you the general outline of the concept.

In your design, you’d need to mate multiple sets of arrays and loop through them:

QuestionArray

RightAnswerArray

FailedQuetionFlagArray

ResponseArray

Cycle through the array set, hit a ‘miss’ question, pop a dialog (could be a ‘real’ dialog box or just an input box) for a comment, stuff the response into the proper array, continue.

Just some ideas.

Doug

Subject: RE: Getting Customized User Input

I was thinking along those lines (without the array), but I’m not happy with using the standard prompt screen and wanted to see if I could somehow use a dialogbox where I could change the look and content (bold text, colors, tables) to present to the reviewer. Any ideas on how to pass this info to a dialogbox instead of doing it this way?

Sub Click(Source As Button)

Dim session As New NotesSession

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = workspace.CurrentDocument

Dim review_stat As String

Dim pf As String

Dim check1 As Integer

Dim check1_note As String

Dim check2 As Integer

Dim check2_note As String

Dim failed_data(1 To 50, 0 To 2) As Variant

Dim i As Long

Dim x As Long

Dim count As Long

Dim uName As NotesName

Set uName = session.CreateName(session.UserName)

abb=uName.Abbreviated

cn=uName.Common

count = 0

review_stat = "Approved"

For i = 1 To 50

	num = i

	pf = uidoc.FieldGetText("pf_" & num)

	If pf = "FAIL" Then

		count=count+1

		failed_data(count,0) = uidoc.FieldGetText("d_" & num)

		failed_data(count,1) = uidoc.FieldGetText("c_" & num)

		Messagebox "Failed question " & Cstr(i) & " - " & failed_data(count,0)

		check1 = workspace.Prompt (PROMPT_YESNOCANCEL,"Is Auditor's Comment Adequate?", "Auditor's Comment: " & failed_data(count,1))

		If check1 = 0 Then

			review_stat = "Rejected"

			check1_note = Inputbox("Comment Rejected","Enter a reason for rejecting the auditor's comment:","")

			Call uidoc.FieldAppendText("app2_notes",", Q" & Cstr(i) & " comment rejected - " & check1_note)

			Call uidoc.Refresh

		Elseif check1 = -1 Then

			Goto leave_script

		End If

		failed_data(count,2) = uidoc.FieldGetText("ia_" & num)

		check2 = workspace.Prompt (PROMPT_YESNOCANCEL,"Is Immediate Action Adequate?", "Immediate Action: " & failed_data(count,2))

		If check2 = 0 Then

			review_stat = "Rejected"

			check2_note = Inputbox("Immediate Action Rejected","Enter a reason for rejecting the action taken:","")

			Call uidoc.FieldAppendText("app2_notes",", Q" & Cstr(i) & " action rejected - " & check2_note)

			Call uidoc.Refresh

		Elseif check2 = -1 Then

			Goto leave_script

		End If

	End If

Next i

If review_stat = "Approved" Then

	Call uidoc.FieldSetText("name_2",abb)

	Call uidoc.FieldSetText("date_2",Cstr(Now))

	Call uidoc.FieldSetText("app2_notes","")

	Call uidoc.Refresh

Elseif review_stat = "Rejected" Then

	Call uidoc.FieldAppendText("app2_notes",", Audit Notes/Actions Rejected by " & cn & " on " & Cstr(Now))

	Call uidoc.Refresh

End If

Leave_script:

End Sub

Subject: RE: Getting Customized User Input

I was able to get this to work using Dialogbox and a new form that displays the failed question one at a time, and accepts user input, then transfers it back to the original checklist and e-mails the response. Seems to work well so far:

Sub Click(Source As Button)

Dim session As New NotesSession

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = workspace.CurrentDocument

Dim review_stat As String

Dim pf As String

Dim q_num As String

Dim q_status As String

Dim q_item As String

Dim q_note As String

Dim q_action As String

Dim rev_note_1 As String

Dim rev_note_2 As String

Dim rca As String

Dim rcb As String

Dim note_ar As String

Dim ia_ar As String

Dim aid As String



Dim failed_data(1 To 50, 0 To 2) As Variant

Dim i As Long

Dim x As Long

Dim count As Long

Dim uName As NotesName

Set uName = session.CreateName(session.UserName)

abb=uName.Abbreviated

cn=uName.Common

count = 0

review_stat = "Approved"

aid = uidoc.FieldGetText("audit_id")

'Call uidoc.FieldSetText("app1_notes","")

For i = 1 To 50

	num = i

	pf = uidoc.FieldGetText("pf_" & num)

	If pf = "FAIL" Or pf = "PARTIAL" Then

		count=count+1

		failed_data(count,0) = uidoc.FieldGetText("d_" & num)

		failed_data(count,1) = uidoc.FieldGetText("c_" & num)

		failed_data(count,2) = uidoc.FieldGetText("ia_" & num)

		q_num = Cstr(i)

		q_status = pf

		q_item = failed_data(count,0)

		q_note = failed_data(count,1)

		q_action = failed_data(count,2)

		Call uidoc.FieldSetText("note_ar","")

		Call uidoc.FieldSetText("ia_ar","")

		Call uidoc.FieldSetText("q_num",q_num)

		Call uidoc.FieldSetText("q_status",q_status)

		Call uidoc.FieldSetText("q_item",q_item)

		Call uidoc.FieldSetText("q_note",q_note)

		Call uidoc.FieldSetText("q_action",q_action)

		If Not workspace.DialogBox( "Failed Question Dialog", False, False, False, False, False, False, "Review" ) Then	

			Dim askme As Integer

			askme = workspace.Prompt(PROMPT_YESNO, "ACTION CANCELLED", "Would you like to clear previously entered comments?")

			If askme = 1 Then

				Call uidoc.FieldSetText("app1_notes","")

			End If				

			Call uidoc.Refresh

			Goto Leave_script

		End If

		

		Call uidoc.Refresh

		rev_note_1 = uidoc.FieldGetText("rca")

		rev_note_2 = uidoc.FieldGetText("rcb")

		

		If uidoc.FieldGetText("note_ar") = "Reject"  Then

			review_stat = "Rejected"

			Call uidoc.FieldAppendText("app1_notes",", Question " & Cstr(i) & " comment rejected - " & rev_note_1)

			Call uidoc.FieldSetText("note_ar","")

			Call uidoc.FieldSetText("rca","")

			Call uidoc.Refresh

		End If

		

		If uidoc.FieldGetText("ia_ar") = "Reject"  Then

			review_stat = "Rejected"

			Call uidoc.FieldAppendText("app1_notes",", Question " & Cstr(i) & " action rejected - " & rev_note_2)

			Call uidoc.FieldSetText("ia_ar","")

			Call uidoc.FieldSetText("rcb","")

			Call uidoc.Refresh

		End If

	End If

Next i

If review_stat = "Approved" Then

	Call uidoc.FieldSetText("name_1",abb)

	Call uidoc.FieldSetText("date_1",Cstr(Now))

	Call uidoc.FieldSetText("app1_notes","")

	Call uidoc.Refresh

Elseif review_stat = "Rejected" Then

	Call uidoc.FieldAppendText("app1_notes",", Audit Notes/Actions Rejected by " & cn & " on " & Cstr(Now))

	Call uidoc.Refresh

End If



notes$ = uidoc.FieldGetText("app1_notes")

Dim db As NotesDatabase

Dim newdoc As NotesDocument

Set thisdoc = uidoc.Document

Dim rtitem As NotesRichTextItem

Set db=session.currentdatabase

Set newdoc=New NotesDocument(db)

newdoc.form = "Memo"

newdoc.subject="Internal Audit " & aid & " " & review_stat

newdoc.sendto=thisdoc.la_name(0)

newdoc.copyto=""

Set rtitem = New NotesRichTextItem( newdoc, "body" )

Call rtitem.AppendText( notes$)

Call rtitem.AddNewLine( 2 )

Call rtitem.AppendText( "Link to checklist => ")

Call rtitem.AppendDocLink( thisdoc, {} )   'adds link to previous text above.

Call newdoc.Send( False) 

Messagebox "The auditor has been notified of your review."

Call uidoc.Save

Call uidoc.Close

Leave_script:

End Sub