Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Search Records and Print (Single Record) Script


MikeAz

Recommended Posts

Hi,

 

None of the other posts on this topic has been particularly useful to my attempted script, so I decided to post a project specific topic.

 

I am attempting to create a script that allows the user to search for a record and then enters a print preview showing only that record. I have created two scripts that, when used independently one after the other, do exactly what I want, however when combined into one script the Preview Mode shows all records. The Script is only 3 steps (run script, pause, run script) however I have included the steps for the other scripts in sequence for reference:

 

Script : Lot Cover Sheet Search/Print

Perform Script ["Lot Cover Search"]

Script: Lot Cover Search

New Window[]

Go to Layout ["Lot Cover/Conformance Report" (LotRegTab)]

Show All Records

Go to Field [LotRegTab::LotNo]

Enter Find Mode

Pause/Resume Script [indefinately]

Perform Script ["Lot Cover Print"]

Script: Lot Cover Print

Enter Preview Mode[]

Print Setup [Restore; No dialog]

 

I’m not exactly sure why I am seeing all records when I use the above script, but when I separate the scripts (exactly as they a written above) and run them sequentially I am getting the desired results (i.e. only seeing the one record I searched for in the preview).

 

If anyone can provide an explanation or give some advice it would be appreciated.

 

Thanks,

 

Mike

Link to comment
Share on other sites

Never mind, I was able to figure it out myself. It seems the other forums were useful, it’s just nobody explained why this particular step would work. I used the following script, hopefully it will help someone else:

 

New Window[]

Go to Layout [“Lot Cover/Conformance Report” (LotRegTab)]

Enter Find Mode [Pause]

Show All Records

Go to Field [LotRegTab::LotNo]

Perform Find[]

Pause/Resume Script [indefinitely]

Omit Record

Show Omitted Only

Enter Preview Mode []

Print Setup [Restore; No dialog]

 

So what is happening is that when I run the script (in this case from a button), a new window opens the Lot Cover Layout in Find Mode. Next the Database shows all records (so it may search all records) then goes to the LotNo field. Here I can type in my search criteria (as the script has paused), and once I hit enter it performs a search based on the criteria entered. It temporarily omits (or isolates) the record/s found and then enters Preview Mode, sets up the Printer to print Portrait and shows the omitted record/s in Preview Mode.

 

It is really simple and straight forward once you understand what the “omit record” function does, but it certainly took a lot of research to figure all this out. I would have thought that when you perform a search the Preview Mode would reflect what you just searched for, but it doesn’t.

Link to comment
Share on other sites

Hey Mike,

 

I had trouble understanding what you were getting at before.

 

Preview Mode always shows starting from the first record in the found set. If you want a Preview script to show only the current record, then isolating it is necessary. This could be done with a self-join relationship on the record ID, or with the Show All/Omit Record/Show Omitted snippet that you discovered.

 

But I think the script that you've settled on could be cleaned up a bit. If the goal is just to preview/print the current record (but leave the found set intact), I'd suggest this:

 

New Window["Preview"]

Show All Records

Omit Record

Show Omitted

Print Setup[Restore]

Enter Preview Mode[]

Adjust Window[Resize]

Show Custom Dialog["Do you want to print?", "Ok", "Cancel"]

If[Get(lastmessagechoice)=1]

Print[Restore]

End If

Close Window["Preview"]

 

 

There's no reason to enter Find Mode again if you're already on the right record.

Link to comment
Share on other sites



×
×
  • Create New...

Important Information

Terms of Use