AnsweredAssumed Answered

Faulty Find Script

Question asked by NaturSalus on Feb 16, 2012
Latest reply on Feb 16, 2012 by NaturSalus

Title

Faulty Find Script

Post

Hello,

In my project the Tool bar is hidden so I have to reproduce the Find capabilities through scripting.

My current setting is as follows:

 

From Manual_Detail layout the Find Script is triggered through the Find button.

From the Manual_Detail layout the Find Script takes the user to the Manual_Find layout where he/she can enter the find criteria.

Once the find criteria has been entered, the user clicks the Continue button on the Manual_Find layout and the following message pops up:

would you like to show the found set of records in Form and List view?

Based on the user choice, the Find scripts takes him/her to the Manual_Form or the Manual_List layout and from there the user can print the record found set using the Current Record Found Set Print script.

As it is set up, every time that the user carries out a find / search that results in a found set > 1, the message:

would you like to show the found set of records in Form and List view?

should always pop up.

But, it doesn't.

My problem is that for any find /search where the found set is larger than 1  (more than 1 record in the found set) sometimes the above mentioned messages shows up but most of the time it doesn't and takes me directly to the Manual_Form layout

So the Find script is for sure faulty but I can't figure aout where.

 

A hand is requested to make work the Find script consistently.

 

The main scripts used are the following:

 

Find Script:

# Error Handling
Allow User Abort [ Off ]
Set Error Capture [ On ]


Set Variable [ $LastLayout; Value:Get(LayoutNumber) ]
Perform Script [ “Save TO” ]
Go to Layout [ LeftWords(Get(LayoutName); 1) & "_Find" ]
Enter Find Mode [ ]


Loop


Modify Last Find
Pause/Resume Script [ Indefinitely ]
Perform Find [ ]


If [ Get(LastError) = 400 ]
Freeze Window
Show Custom Dialog [ Title: "No Find Criteria"; Message: "No find criteria was entered."; Buttons: “OK” ]
Go to Layout [ original layout ]
Exit Loop If [ 1 ]


# when no records are found


Else If [ Get(FoundCount) = 0 ]
Show Custom Dialog [ Title: "No " & Proper(LeftWords(Get(LayoutName); 1)) & " Found"; Message: "No " & Lower(LeftWords
(Get(LayoutName); 1)) & " were found. Would you like to redefine your find criteria?"; Buttons: “Yes”, “No” ]
If [ Get(LastMessageChoice) = 2 ]
Perform Script [ “Restore TO”; Parameter: $LastLayout ]
Exit Loop If [ 1 ]
End If


# when only one record is found


Else If [ Get(FoundCount) = 1 ]
Perform Script [ “Form View” ]
Exit Loop If [ 1 //one record was found ]


# when more than one record are found


Else
Show Custom Dialog [ Title: "Show as a Form or as a List"; Message: "Would you like to show the found set of records in Form
or List View)"; Buttons: “Form”, “List” ]
If [ Get ( LastMessageChoice ) = 1 ]
Perform Script [ “Form View” ]
Exit Loop If [ 1 //one or more records were found ]
End If
Perform Script [ “List View” ]
Exit Loop If [ 1 //one or more records were found ]
End If


End Loop

 

Form View Script

# Error Handling
Allow User Abort [ Off ]
Set Error Capture [ On ]


# found set is shown in the TableName_Form layout
Go to Layout [ LeftWords(Get(LayoutName); 1) & "_Form" ]
Pause/Resume Script [ Indefinitely ]


# back to the original layout
Go to Layout [ LeftWords(Get(LayoutName); 1) & "_Detail" ]
Show All Records
Unsort Records

 

 

List View Script

# Error Handling
Allow User Abort [ Off ]
Set Error Capture [ On ]


# found set shown in the TableName_List layout
Go to Layout [ LeftWords(Get(LayoutName); 1) & "_List" ]
Pause/Resume Script [ Indefinitely ]


# back to the original layout
Go to Layout [ LeftWords(Get(LayoutName); 1) & "_Detail" ]
Show All Records
Unsort Records

 

 

Save TO Script


# Error Handling
Allow User Abort [ Off ]
Set Error Capture [ On ]
#
If [ LeftWords(Get(LayoutName); 1) = "Manual" ]
Go to Related Record [ From table: “Manual”; Using layout: “Manual_saveTO” (MANUALsaveTO) ]
[ Show only related records ]
Else If [ LeftWords(Get(LayoutName); 1) = "Procedure" ]
Go to Related Record [ From table: “Procedure”; Using layout: “Procedure_saveTO” (PROCEDUREsaveTO) ]
[ Show only related records ]
Else If [ LeftWords(Get(LayoutName); 1) = "ProcedureForm" ]
Go to Related Record [ From table: “procedure_FORM”; Using layout: “ProcedureForm_saveTO ” (procedureFORMsaveTO) ]
[ Show only related records ]
Else If [ LeftWords(Get(LayoutName); 1) = "ProcedureRecord" ]
Go to Related Record [ From table: “procedure_RECORD”; Using layout: “ProcedureRecord_saveTO” (procedureRECORDsaveTO) ]
[ Show only related records ]
Else If [ LeftWords(Get(LayoutName); 1) = "WorkInstruction" ]
Go to Related Record [ From table: “Work Instruction”; Using layout: “WorkInstruction_saveTO ” (WorkINSTRUCTIONsaveTO) ]
[ Show only related records ]
Else If [ LeftWords(Get(LayoutName); 1) = "WorkInstructionForm" ]
Go to Related Record [ From table: “workI_FORM”; Using layout: “WorkInstructionForm_saveTO ” (workInstFORMsaveTO) ]
[ Show only related records ]
Else If [ LeftWords(Get(LayoutName); 1) = "WorkInstructionRecord" ]
Go to Related Record [ From table: “workI_RECORD”; Using layout: “WorkInstructionRecord_saveTO” (workInstRECORDsaveTO) ]
[ Show only related records ]
Else If [ LeftWords(Get(LayoutName); 1) = "Document" ]
Go to Related Record [ From table: “Document”; Using layout: “Document_saveTO Copy” (DOCUMENTsaveTO) ]
[ Show only related records ]
Else If [ LeftWords(Get(LayoutName); 1) = "DocumentForm" ]
Go to Related Record [ From table: “document_FORM”; Using layout: “DocumentForm_saveTO ” (documentFORMsaveTO) ]
[ Show only related records ]
Else If [ LeftWords(Get(LayoutName); 1) = "DocumentRecord" ]
Go to Related Record [ From table: “document_RECORD”; Using layout: “DocumentRecord_saveTO ” (documentRECORDsaveTO) ]
[ Show only related records ]
End If
Go to Layout [ original layout ]

 

 

Restore TO Script


# Error Handling
Allow User Abort [ Off ]
Set Error Capture [ On ]
#
Go to Layout [ LeftWords(Get(LayoutName); 1) & "_saveTO" ]
If [ LeftWords(Get(LayoutName); 1) = "Manual" ]
Go to Related Record [ From table: “MANUALsaveTO”; Using layout: Get(ScriptParameter) ]
[ Show only related records ]
Else If [ LeftWords(Get(LayoutName); 1) = "Procedure" ]
Go to Related Record [ From table: “PROCEDUREsaveTO”; Using layout: Get(ScriptParameter) ]
[ Show only related records ]
Else If [ LeftWords(Get(LayoutName); 1) = "ProcedureForm" ]
Go to Related Record [ From table: “procedureFORMsaveTO”; Using layout: Get(ScriptParameter) ]
[ Show only related records ]
Else If [ LeftWords(Get(LayoutName); 1) = "ProcedureRecord" ]
Go to Related Record [ From table: “procedureRECORDsaveTO”; Using layout: Get(ScriptParameter) ]
[ Show only related records ]
Else If [ LeftWords(Get(LayoutName); 1) = "WorkInstruction" ]
Go to Related Record [ From table: “WorkINSTRUCTIONsaveTO”; Using layout: Get(ScriptParameter) ]
[ Show only related records ]
Else If [ LeftWords(Get(LayoutName); 1) = "WorkInstructionForm" ]
Go to Related Record [ From table: “workInstFORMsaveTO”; Using layout: Get(ScriptParameter) ]
[ Show only related records ]
Else If [ LeftWords(Get(LayoutName); 1) = "WorkInstructionRecord" ]
Go to Related Record [ From table: “workInstRECORDsaveTO”; Using layout: Get(ScriptParameter) ]
[ Show only related records ]
Else If [ LeftWords(Get(LayoutName); 1) = "Document" ]
Go to Related Record [ From table: “DOCUMENTsaveTO”; Using layout: Get(ScriptParameter) ]
[ Show only related records ]
Else If [ LeftWords(Get(LayoutName); 1) = "DocumentForm" ]
Go to Related Record [ From table: “documentFORMsaveTO”; Using layout: Get(ScriptParameter) ]
[ Show only related records ]
Else If [ LeftWords(Get(LayoutName); 1) = "DocumentRecord" ]
Go to Related Record [ From table: “documentRECORDsaveTO”; Using layout: Get(ScriptParameter) ]
[ Show only related records ]
End If

 

Thanks,

natursalus

Outcomes