3 Replies Latest reply on Feb 29, 2012 2:48 PM by philmodjunk

    Adding another view to the calendar

    Kat11_1

      Title

      Adding another view to the calendar

      Post

      Thank you Phil for sharing this great calendar!  http://www.4shared.com/file/6UAOV_RZ/Calendar.html Has anyone  added a Week View option to it? I would like to do it but I am not sure how to go about it.

      If I go with a form view and use Go To Record / Request to move  between records ( to the next or previus week) than I need to figure out how to "refresh" the week table when I get to the last (first) week of the "current" month.

      Could adding an If statement that would triger Create Month subscript and pass the respective Script Parameter if I am on the 1st or last record work?

        • 1. Re: Adding another view to the calendar
          philmodjunk

          As currently designed, the Week table is only used for display purposes. The records are created and deleted as needed as you move from month to month.The controls at the top of the layout invoke scripts that create and delete these records as needed for the particular button clicked. click the button to see next month and the script deletes all Week records and then creates the needed 4 to 7 new Week Records to display the event dates for the next month.

          If you wanted to, a "next week" script could delete the oldest Week Record and create one with a date that was 7 days later than the newest Week record--though you'll need to decide what this will mean for the parts of the layout that are designed to display the name of the current month and those intended to take to the next or previous months.

          A single week view of the data could be created with list view, table view, or portal to the events table.

          With a list or table view, A find or go to related records step could be used to pull up all records for a given week as the current found set. Controls in the header of such a layout could invoke scripts that perform the needed finds to pull up previous, next or specified weeks for view of the data.

          In a portal, the relationship or a portal filter can be manipulated to match to records of different weeks.

          With either approach, this calculation can prove handy:

          cWeek:    EventDate - DayofWeek ( EventDate ) + 1

          This returns the date for Sunday of the same week as EventDate so if you define this as a calculation in the events table, all records for the same week will have a common value to use as your find criteria, in the relationship or in a portal filter.

          • 2. Re: Adding another view to the calendar
            Kat11_1

            Thank you Phil. I know I am changing the focus here but I've been trying to add another portal to display  the events  from another table. I incresead the width of a "day box" to accommodate two portals.

            I've relationsheeps as follows.

            File::cWeek>---< Weeks::Weeks   Where calcualtion for cWeek is  =CloseDate - DayOfWeek ( CloseDate ) + 1 as you say above.

            On the layout based on Week table I have a portal which is based on File table that filters based on DayOfWeek(File::CloseDate) all the records that meet the criteria show properly.

            I would like to add a portal that would display records from FileData table. I added cWeek=TaskDate - DayOfWeek ( TaskDate ) + 1 to the FileData table.

            I created a 2nd occurance of FileData table and try to create a relationship FileData::cWeek >---<Weeks::Week but I always get FileData::cWeek |---< Weeks::Week. And no records display in this portal. I am pretty sure my relationship is off but don't know how to fix it.

            • 3. Re: Adding another view to the calendar
              philmodjunk

              Check the storage info for FielData::cWeek  |--- usually indicates that the field on that end of the line is unstored or global. That can work with some relatioships, but not for the side of the relationship supplying records to a portal. Also make sure that cWeek has Date specified as its return type in the calculation.

              Note: a calculation field can be specifically defined to be "unstored" in storage options, but often it is unstored because it references a global or unstored field in its calculation. You'll need to study your design to figure out how to get it to be a stored calculation field before you can use it in such a relationship.

              Hmmm, I'd have to double check the original demo file to be sure, but I think you could use this relationship between weeks and FileData and let the portal filter do all the work in controlling what records appear in it:

              Weeks::anyfield X FileData::anyField