7 Replies Latest reply on Apr 11, 2010 1:17 PM by Jigzat

    How to copy values from find results into different layout

    Jigzat

      Title

      How to copy values from find results into different layout

      Post

      Hello everyone, this is what I am trying to do:

       

      I have a layout where I search for records with an empty date in certain field

      then I use the results to copy one text field into a new record text field in a different layout

      I do this for every empty date found record

       

      So far I have been using the Copy [] function which uses the clipboard, and it works but it is not the right way to do it.

      I tried with variables and Insert text [], set field [] but it doesn't work, the field in the recently created record is empy

       

      I used the debugger and the variable actualy holds the data but set field [] doesn't set the field.

       

      Can someone help me out with this?

       

      This is the code:

       

       

      Perform FInd [restore]
      Go to Record/Request/Page [first]
      Loop
      Set Variable [$$TENENCIA_FA; Value:Tenencias::Tenencia]
      Go to Layout ["Saldos" (Saldos)]
      New Record/Request
      Insert Current Date [Select; Saldos::Fecha Facturacion]
      Insert Text [Select; Saldos::Detalle; "CUOTA ADMINISTRACION"]
      Set Field [Saldos::Tenencia;$$TENENCIA_FA]
      Go To Layout [original layout]
      Go To Record/Request/Page [Next; Exit after last]
      End Loop
      Copy [Select]

       

       

        • 1. Re: How to copy values from find results into different layout
          LaRetta_1

           


          Jigzat wrote:...

          the data but set field [] doesn't set the field.


          Your script works as presented (I just created an identical file and script) although I suggest that you use Set Field[] for Saldos::Fecha Facturacion and Saldos::Detalle as well.  If those two fields aren't on the layout then both 'Insert' steps will fail (that is one of their shortcomings) whereas Set Field[] is always the best choice (when possible).  Even so, if those two fields remain empty because they throw a 102 error (field is missing), I show that your Saldos::Tenencia would still inherit the $$TENENCIA_FA variable.  Even if you have invalid data type on Tenencia (between your two tables), it still would properly set the field in the newly created record.
          When you perform your find, are you sure you have found records?  If you have no records in your found set when you start, it will go ahead and create a new record in Saldos and even insert date and text but it won't set it with Tenencia because no records are displayed in your loop.  The other possibility is that you are starting your script from the wrong layout (while testing).  Sometimes when we fire a script from ScriptMaker we don't make sure we are on proper layout to start, particularly when your script says 'go to original layout' instead of specifying the specific layout ... this can get you in trouble when testing.

          So I would suggest the following changes:

           

          Set Error Capture [ On ]
          Perform FInd [restore]
          If [ not Get ( LastError ) and Get ( FoundCount ) ]
          Go to Record/Request/Page [first]
          Loop
          Set Variable [$$TENENCIA_FA; Value:Tenencias::Tenencia]
          Go to Layout ["Saldos" (Saldos)]
          New Record/Request
          Set Field [ Saldos::Fecha Facturacion ; Get ( CurrentDate ) ]
          Set Field [ Saldos::Detalle; "CUOTA ADMINISTRACION"]
          Set Field [Saldos::Tenencia;$$TENENCIA_FA]
          Go To Layout [ 'layout holding this original found set' ; Tenencias ]
          Go To Record/Request/Page [Next; Exit after last]
          End Loop
          End If

          Also, there is probably no need to use a global variable.  A script variable will persist only while within this script (use single $ instead of two) and that will be fine.  I only use global variables if the value must persist after a script ends.  If this doesn't work, it would help to see your file.:smileyhappy:








          • 2. Re: How to copy values from find results into different layout
            LaRetta_1

            BTW, if you have several records in your found set, some might say an import is the way to go. 

             

            But do NOT trust imports ... they will bite you repeatedly.  Imports are dangerous!!!

            • 3. Re: How to copy values from find results into different layout
              Jigzat

              Hey thanks for the quick answer. I made the suggested modifications and it is still not working. As far as I know the find function is throwing results. When I was using the Copy function it worked as spected.

               

              Do you mind taking a look at the DB?

               

              The script is called "Facturar Administracion"

               

              http://www.protectlinks.com/277830

              • 4. Re: How to copy values from find results into different layout
                LaRetta_1

                It requires my credit card information first even for free trial and before it will allow a download.  I don't mind a site requiring my email but requiring a credit card to verify that I am eligible to pay the bill should they decide to charge after the free trial ... nope, sorry.

                 

                If you wish to upload your file to any of the other truly 'free' sites, such as 4share, I would be most happy to take a look.  :smileyhappy:

                • 5. Re: How to copy values from find results into different layout
                  Jigzat

                  Sorry I didn't know it was asking for a credit card or email. When I click the link it doesn't ask me all that information. Try this one, it's a MobileMe link

                   

                  DataBase

                  • 6. Re: How to copy values from find results into different layout
                    LaRetta_1

                    Thanks for the new link ... I didn't mind providing my email but I didn't want to provide my debit card (I've been bitten by that in the past). 

                     

                    In your Facturar Administracion script, there is an extra space in your Set Variable step:  $$TENENCIA _FA (right before the underline).  If you remove that space, it will then match your Set Field [] script-step instance of the variable and it properly sets the field.  It was not easy to spot. And yes, it would be nice if FMI could warn us when (within a script) we are defining a script variable which isn't correct but I understand why it would be difficult to catch.  :smileyhappy:

                     

                    I hope the rest of your weekend goes well!

                    • 7. Re: How to copy values from find results into different layout
                      Jigzat

                      LaRetta thank you very very much for your help, this forum is excellent, Super Contributors should get paid for that or at least get discount on Filemaker :smileywink: . It is very weird that protectlinks.com ask you for a credit card, maybe is thanks to the fact that you are in the USA because I'm in Colombia and when I click the link it just take me to the download page.

                       

                      I hope you weekend goes well too.

                       

                      Best Wishes