3 Replies Latest reply on Nov 5, 2012 10:42 AM by philmodjunk

    Get date to new layout

    heidisagat

      Title

      Get date to new layout

      Post

           I have a table with two datefield, date1 and date2.

           I can search for records "from date" to "to date".

           I have used this script

           If [IsEmpty (ExampleTable::GlobalStartDate)]
                 Show Custom Dialog ["("Start Date";"Start Date must have a value. Please reenter"]
                 Exit Script []
           End If
           If [IsEmpty (ExampleTable::GlobalEndDate)]
                 Show Custom Dialog ["End Date";"End Date must have a value. Please reenter"]
                 Exit Script []
           End If
           If [ExampleTable::GlobalEndDate < ExampleTable::GlobalStartDate]
                 Show Custom Dialog ["Invalid Date Range";"End Date cannot occur before Start Date. Please reenter"]
                 Exit Script []
           End If
           Go to Layout ["Layout #1"]
           Enter Find Mode []
           Set Field [ExampleTable::Date1 ; ExampleTable::GlobalStartDate & "..." & ExampleTable::GlobalEndDate]

           New Record/Request

           Set Field [ExampleTable::Date2 ; ExampleTable::GlobalStartDate & "..." & ExampleTable::GlobalEndDate]
           Perform Find []

           I want this records shown in another layout and get the date found either in date1 or date2. 

           Can somebody help me?

        • 1. Re: Get date to new layout
          philmodjunk

               But is the other layout based on the same table occurrence?

               This is a key question. If you see the same exact name in Layout Setup | Show Records From for both layouts, they both refer to the same found set of records and you can just add these steps to the end of your script:

               Set Error Capture [on]
               Perform Find []
               Go To Layout [//specify other layout here]

               If they are not based on the same table occurrence, then you will need to make two changes:

               Change to layout #2 before specifying find criteria

               Change the set field steps to enter search criteria into the date field(s) of this other layout's table occurrence.

          • 2. Re: Get date to new layout
            heidisagat

                 Both layouts is in the same table.

                 I want to get the date(s) found from either Date1 og Date2 in a new field "founddate" in layout #2. How do I do this?

            • 3. Re: Get date to new layout
              philmodjunk

                   How do you determine whether to refer to date1 or Date2? What logic determines from which field to copy this data?

                   You have also found what is potentiall an entire group of records, in which of these records will you modify the founddate field with this date?

                   if "founddate" is defined in the same table, all you need is one of these two steps:

                   Set Field [ExampleTable::founddate ; ExampleTable::Date1 ]

                   or

                   Set Field [ExampleTable::founddate ; ExampleTable::Date2 ]

                   But you have to determine from which table to get the date and into which found record to enter it.

                   Depending on how you use founddate, you may not need this field at all or you may find it useful to specify global storage for it.