14 Replies Latest reply on Oct 29, 2013 10:03 AM by JohhnyHilly

    Printing assistance required

    JohhnyHilly

      Title

      Printing assistance required

      Post

           I am having trouble setting up a layout so it prints exactly what I want.

           I have 2 tables, Vehicles and Oil Samples, that are connected via a primary and foreign key. One vehicle will have multiple oil samples on different dates. I would like to show the following but am having trouble with it. Currently the layout is based on the table Oil Samples.

           1. I would like fields/data to display from the most recent oil sample. So far I have created a table occurence of Oil Samples (called Oil Sample Printing) and I have connected it to Oil Samples via the foreign key of each occurence. I created a portal in the layout BODY and linked it to Oil Samples Printing, and formatted it so it only has one row and is sorted by date. Problem is it is showing all the oil samples, not just the most recent one. (Note: all oil samples are not displaying in the same portal but displaying like each record is in a different portal).

           How can I have it so it only shows the most recent oil sample? 

           2. Below the portal above, I would like exactly the same thing, except the next 4 oil samples after the most recent one. I have yet to work out how to do this.

           I am not sure if I am using the parts in the layout incorrectly of not but from first impression it seems like I am.

           Any help would be appreciated.

        • 1. Re: Printing assistance required
          philmodjunk

               Base your layout on Vehicles. Then put fields from Oil Samples on this layout. Use either a relationship sorted so that the most recent sample is the first related record or use a one row portal to oil samples that is sorted in this fashion.

          • 2. Re: Printing assistance required
            JohhnyHilly

                 I tried this initially Phil, but it shows the records for all the vehicles in the body. I am only wanting to show the oil samples of one vehicle at any one time (which ever is in the found set or current record).

            • 3. Re: Printing assistance required
              philmodjunk

                   Just putting the layout into form view instead of list or table view may be all that you need do.Or you could limit your found set to just the vehicle in question. That can be done with a scripted find, go to related records.

              • 4. Re: Printing assistance required
                JohhnyHilly

                     It was already in form view. I have actually done the scripted find by go to related records already. I have used this method as my "Print" button. The script is attached. However, this still shows the first oil sample record for every vehicle, not the vehicle in question. Is my Go to Related Records in the script correct?

                • 5. Re: Printing assistance required
                  philmodjunk
                       

                            It was already in form view.

                       It is not possible for a layout based on Vehicles to show data from all vehicles records in the body of the layout if the fields from Vehicles are placed directly on the layout. You'll only see the data for one vehicle at a time in form view. Are you perhaps using a portal here?

                       Whether or not it is the desired vehicle record would be the next issue to check. Nothing in your script selects for a specific vehicle, it just replicates the current found set in the new window--and that found set could be anything from one record to all records in the vehicles table.

                       What layout are you on and what table occurrence is that layout based on, when you perform this script?

                  • 6. Re: Printing assistance required
                    JohhnyHilly
                         

                    It is not possible for a layout based on Vehicles to show data from all vehicles records in the body

                    Yes, you are correct in saying that and on my "Print/Sent Oil Samples" layout it only shows the one record in form view. However, when I press my "Print" button with the above script, it creates a PDF that shows the first oil sample record for every vehicle (not the most recent).

                         Are you perhaps using a portal here?

                    Yes, I was but even with the fields placed directly on the layout the same thing happened above.

                         What layout are you on and what table occurrence is that layout based on, when you perform this script?

                         I am on the layout called "Oil Samples" that is based on the table Vehicles and has a portal on it linked to Oil Samples.

                    • 7. Re: Printing assistance required
                      philmodjunk
                           

                      However, when I press my "Print" button with the above script, it creates a PDF that shows the first oil sample record for every vehicle (not the most recent).

                      You need to select "current record" instead of "Records being browsed" in the save as PDF step.

                      • 8. Re: Printing assistance required
                        JohhnyHilly

                             Phil, I can't get this to work. I am going from a layout based on Vehicles with a portal to Oil Samples to a print layout based on Vehicles with the fields from Oil Samples placed directly on the layout but nothing is displaying. Do I have to select/find a specific vehicle (as you mentioned above), then select/find a specific oil sample for it to display on the print layout?

                             I'm guessing you would use Set Variable and Set Field but what would that look like? (I still don't fully understand those which is why I am asking) Also, should I be printing from a layout based on Vehicles or Oil Samples? Thanks.

                        • 9. Re: Printing assistance required
                          philmodjunk

                               What are you doing differently?

                               Earlier, you reported that your PDF had all the records instead of just the current record. A single change to the options for Save As pdf in order to specify current record should be the only change needed for that PDF to contain data from just one record instead of all the records.

                               If both layouts have the same table occurrence selected "show records from", then they will have the same current record. All you need do in that case is change layouts with a go to layout step, then be sure to PDF or print with the current record option specified.

                               If the layouts are based on different table occurrences of Vehicles, then they will have different current records and found sets and in that case either a scripted find or Go To Related records step (which requires the correct relationship) would be used to pull up the same record on the second layout.

                          • 10. Re: Printing assistance required
                            JohhnyHilly

                                 The values in the fields weren't updating correctly, that's why I thought it was right.

                                 I only have one table/table occurence for Vehicles. Both the layout with the portal on and the print layout are based on the same Vehicles table. I realised that I wasn't setting the current record properly, but even when I did that the information is not displayed on the print layout.

                                 Now if I change the print layout to be based on Oil Samples the correct values come into the fields. I think the reason was that when I am on a layout that is based on Vehicles, there is no oil sample that is the current record so it doesn't display anything. If I only want to print one record at a time, it should be ok if the print layout is based on Oil Samples correct?

                                 One big question, how do I specifically make an Oil Sample record the active record. For the purpose of finding the solution to the above problem I just went Show All, Omit Record, Show Omitted Only to make a record current. With a script, how can I make a certain oil sample record current before or as I am printing it?

                            • 11. Re: Printing assistance required
                              philmodjunk

                                   But when you change to a layout based on oil samples, you will also need to include code that finds the correct oil sample record. This should not be necessary if you use a layout based on Vehicles. To repeat what I posted earlier:

                                   If you base the layout on Vehicles, you should be able to include fields from oil samples on your layout. To get the data from the most recent oil sample record for that vehicle, either define the relationship to sort the records so that the most recent record is the first related record or put the fields inside a one row portal that is sorted to show the most recent oil sample record.

                              • 12. Re: Printing assistance required
                                JohhnyHilly

                                     Ok. Done. Apologies for my slowness. I was trying to do two things at once. Many thanks.

                                     I would also like to have the option to print an oil sample of my choice (as opposed to just printing the most recent). What would the code/script look like to select this and would the printing layout be based on oil samples?

                                      

                                • 13. Re: Printing assistance required
                                  philmodjunk

                                       The details will depend on what the user does to select that oil sample and yes, this will likely be best printed/PDF'd from a layout based on Oil Samples.

                                       If you have a list of Oil Samples data listed in a portal, a button in the portal row could be clicked to select and print the oil sample record shown in the portal row. Go To Related Records is made to order for that interface design.

                                  • 14. Re: Printing assistance required
                                    JohhnyHilly

                                         Ok, sounds more simple than I thought. All working ok. Many thanks for your help Phil, again.