Creating Calendar for Timesheet

Certified Associate Developer

Hi,

I need to create an interface for timesheet entry.  In the interface when I select the month and year the calendar for that month should be displayed in a grid with days (1, 2 ,3 etc) as links so that I can click the link to enter the number of hours worked on that day.  How can I acheive this?  I need to create this interface in 18.1 version.  Thanks in advance.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    Hi,

    First you need to find out the no. of days in your month. You can do that by using daysinmonth() funtion.
    After you have the no. of days in the selected month, use the function weekday() to create a dictionary object for all the dates that fall under a particular day..for that month..for eg.{monday:{1,7,14},tuesday{2,8,15}..so on}.
    Once you have the dictionary objects, use that in a pagingGrid and provide links that will call a section to enter the no. of hours.
    Your pagingGrid columns will be monday,tuesday,,,,,upto sunday and the values will be the ones from the dictionary object.
  • 0
    Certified Senior Developer
    in reply to Aditya

    Can you tell me the code for this asap

  • I've avoided using plugins, CDTs and referencing other rules but this works Slight smile

    a!localVariables(
      local!blankWeekDictionary: {
        monday: {},
        tuesday: {},
        wednesday: {},
        thursday: {},
        friday: {},
        saturday: {},
        sunday: {}
      },
      local!today: todate(local(now())),
      local!month: month(local!today),
      local!year: year(local!today),
      local!daysInMonth: daysinmonth(
        local!month,
        local!year
      ),
      local!unsortedMonthData: a!forEach(
        items: 1 + enumerate(local!daysInMonth),
        expression: a!localVariables(
          local!date: date(
            local!year,
            local!month,
            fv!item
          ),
          {
            date: local!date,
            dayNumberInMonth: fv!item,
            dayNumberInWeek: weekday(
              local!date,
              2
            ),
            dayName: text(local!date, "dddd")
          }
        )
      ),
      local!sortedMonthData: a!forEach(
        items: 1 + enumerate(7) /*There are 7 days in a week*/,
        expression: a!localVariables(
          local!matchingDayNumberInWeekDetails: index(
            local!unsortedMonthData,
            wherecontains(
              fv!item,
              tointeger(
                index(
                  local!unsortedMonthData,
                  "dayNumberInWeek",
                  {}
                )
              )
            ),
            {}
          ),
          local!matchingDayNumberInMonth: index(
            local!matchingDayNumberInWeekDetails,
            "dayNumberInMonth",
            {}
          ),
          local!matchingDayNumberInMonth
        )
      ),
      reduce(
        a!update,
        local!blankWeekDictionary,
        merge(
          {
            "monday",
            "tuesday",
            "wednesday",
            "thursday",
            "friday",
            "saturday",
            "sunday"
          },
          local!sortedMonthData
        )
      )
    )

Reply Children
No Data