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
Can you tell me the code for this asap
Below is my code . Using this expression i want to display calendar . I am facing problem in displaying .
If you can correct my code ...I will be very thank full .
a!localVariables( local!s:weekday(date(ri!y,ri!m,1),1), local!t:daysinmonth(ri!m,ri!y), choose(local!s, if(local!s=1, a!forEach( items:enumerate(daysinmonth(ri!m,ri!y)), expression:{if(text(date(ri!y,ri!m,fv!item+1),"dddd")="Sunday", { sun:if(fv!item+1<local!t+1,fv!item+1,{}), mon:if(fv!item+2<local!t+1,fv!item+2,{}), tues:if(fv!item+3<local!t+1,fv!item+3,{}), wed:if(fv!item+4<local!t+1,fv!item+4,{}), thurs:if(fv!item+5<local!t+1,fv!item+5,{}), fri:if(fv!item+6<local!t+1,fv!item+6,{}), sat:if(fv!item+7<local!t+1,fv!item+7,{}) } ,{})} ),{}), if(local!s=2, a!forEach( items:enumerate(daysinmonth(ri!m,ri!y)), expression:{if(text(date(ri!y,ri!m,fv!item+1),"dddd")="Monday", { mon:if(fv!item+1<local!t+1,fv!item+1,{}), tues:if(fv!item+2<local!t+1,fv!item+2,{}), wed:if(fv!item+3<local!t+1,fv!item+3,{}), thurs:if(fv!item+4<local!t+1,fv!item+4,{}), fri:if(fv!item+5<local!t+1,fv!item+5,{}), sat:if(fv!item+6<local!t+1,fv!item+6,{}), sun:if(fv!item+7<local!t+1,fv!item+7,{}), } ,{})} ),{}), if(local!s=3, a!forEach( items:enumerate(daysinmonth(ri!m,ri!y)), expression:{if(text(date(ri!y,ri!m,fv!item+1),"dddd")="Tuesday", { tues:if(fv!item+1<local!t+1,fv!item+1,{}), wed:if(fv!item+2<local!t+1,fv!item+2,{}), thurs:if(fv!item+3<local!t+1,fv!item+3,{}), fri:if(fv!item+4<local!t+1,fv!item+4,{}), sat:if(fv!item+5<local!t+1,fv!item+5,{}), sun:if(fv!item+6<local!t+1,fv!item+6,{}), mon:if(fv!item+7<local!t+1,fv!item+7,{}), } ,{})} ),{}), if(local!s=4, a!forEach( items:enumerate(daysinmonth(ri!m,ri!y)), expression:{if(text(date(ri!y,ri!m,fv!item+1),"dddd")="Wednesday", { wed:if(fv!item+1<local!t+1,fv!item+1,{}), thurs:if(fv!item+2<local!t+1,fv!item+2,{}), fri:if(fv!item+3<local!t+1,fv!item+3,{}), sat:if(fv!item+4<local!t+1,fv!item+4,{}), sun:if(fv!item+5<local!t+1,fv!item+5,{}), mon:if(fv!item+6<local!t+1,fv!item+6,{}), tues:if(fv!item+7<local!t+1,fv!item+7,{}) } ,{})} ),{}), if(local!s=5, a!forEach( items:enumerate(daysinmonth(ri!m,ri!y)), expression:{if(text(date(ri!y,ri!m,fv!item+1),"dddd")="Thursday", { thurs:if(fv!item+1<local!t+1,fv!item+1,{}), fri:if(fv!item+2<local!t+1,fv!item+2,{}), sat:if(fv!item+3<local!t+1,fv!item+3,{}), sun:if(fv!item+4<local!t+1,fv!item+4,{}), mon:if(fv!item+5<local!t+1,fv!item+5,{}), tues:if(fv!item+6<local!t+1,fv!item+6,{}), wed:if(fv!item+7<local!t+1,fv!item+7,{}), } ,{})} ),{}), if(local!s=6, a!forEach( items:enumerate(daysinmonth(ri!m,ri!y)), expression:{if(text(date(ri!y,ri!m,fv!item+1),"dddd")="Friday", { fri:if(fv!item+1<local!t+1,fv!item+1,{}), sat:if(fv!item+2<local!t+1,fv!item+2,{}), sun:if(fv!item+3<local!t+1,fv!item+3,{}), mon:if(fv!item+4<local!t+1,fv!item+4,{}), tues:if(fv!item+5<local!t+1,fv!item+5,{}), wed:if(fv!item+6<local!t+1,fv!item+6,{}), thurs:if(fv!item+7<local!t+1,fv!item+7,{}) } ,{})} ),{}), if(local!s=7, a!forEach( items:enumerate(daysinmonth(ri!m,ri!y)), expression:{if(text(date(ri!y,ri!m,fv!item+1),"dddd")="Saturday", { sat:if(fv!item+1<local!t+1,fv!item+1,{}), sun:if(fv!item+2<local!t+1,fv!item+2,{}), mon:if(fv!item+3<local!t+1,fv!item+3,{}), tues:if(fv!item+4<local!t+1,fv!item+4,{}), wed:if(fv!item+5<local!t+1,fv!item+5,{}), thurs:if(fv!item+6<local!t+1,fv!item+6,{}), fri:if(fv!item+7<local!t+1,fv!item+7,{}), } ,{})} ),{}),))
How may I help?
According to my code dates are displaying like this. I am not able to improve my code . how can i?
Want to display the result in read only grid
Had a bit of a play and came up with a few options. I ended up re-working the data to make more sense in how a grid would want the data. Again I have avoided using expression rules, CDTs and plugins.
a!localVariables( local!namesOfDaysInWeek: touniformstring( "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"), inThisMonth: true } ) ), local!firstDayOfMonthData: index( local!unsortedMonthData, 1, {} ), local!firstDayOfMonthOccursOnDayNumber: tointeger( index( local!firstDayOfMonthData, "dayNumberInWeek", {} ) ), local!firstDayOfMonthDate: todate( index( local!firstDayOfMonthData, "date", {} ) ), local!lastDayOfMonthData: index( reverse(local!unsortedMonthData), 1, {} ), local!lastDayOfMonthOccursOnDayNumber: tointeger( index( local!lastDayOfMonthData, "dayNumberInWeek", {} ) ), local!lastDayOfMonthDate: todate( index( local!lastDayOfMonthData, "date", {} ) ), local!numberOfLastMonthDaysToAddToStart: local!firstDayOfMonthOccursOnDayNumber - 1, local!numberOfNextMonthDaysToAddToEnd: 7 - local!lastDayOfMonthOccursOnDayNumber, local!lastMonthDaysToAddToStart: if( local!numberOfLastMonthDaysToAddToStart = 0, {}, reverse( a!forEach( items: 1 + enumerate(local!numberOfLastMonthDaysToAddToStart), expression: a!localVariables( local!date: local!firstDayOfMonthDate - fv!item, { date: local!date, dayNumberInMonth: day(local!date), dayNumberInWeek: weekday( local!date, 2 ), dayName: text(local!date, "dddd"), inThisMonth: false } ) ) ) ), local!nextMonthDaysToAddToEnd: if( local!numberOfNextMonthDaysToAddToEnd = 0, {}, a!forEach( items: 1 + enumerate(local!numberOfNextMonthDaysToAddToEnd), expression: a!localVariables( local!date: local!lastDayOfMonthDate + fv!item, { date: local!date, dayNumberInMonth: day(local!date), dayNumberInWeek: weekday( local!date, 2 ), dayName: text(local!date, "dddd"), inThisMonth: false } ) ) ), local!fullCalendarListOfDays: a!flatten( { local!lastMonthDaysToAddToStart, local!unsortedMonthData, local!nextMonthDaysToAddToEnd } ), local!lengthOfFullCalendarListOfDays: if( rule!CMN_IsEmpty(local!fullCalendarListOfDays), 0, length(local!fullCalendarListOfDays) ), local!numberOfCalendarRows: tointeger(local!lengthOfFullCalendarListOfDays/7), local!fullCalendarAsArray: a!forEach( items: 1 + enumerate(local!numberOfCalendarRows), expression: a!localVariables( local!calendarRow: index( local!fullCalendarListOfDays, 1 + product(fv!item - 1, 7) + enumerate(7), {} ), a!map( monday: index( local!calendarRow, 1, {} ), tuesday: index( local!calendarRow, 2, {} ), wednesday: index( local!calendarRow, 3, {} ), thursday: index( local!calendarRow, 4, {} ), friday: index( local!calendarRow, 5, {} ), saturday: index( local!calendarRow, 6, {} ), sunday: index( local!calendarRow, 7, {} ) ) ) ), { /*Read only grid using a!gridField() - Annoying that the number of items HAS to show at the bottom*/ a!gridField( label: concat( text(local!today, "mmmm"), " ", local!year ), data: local!fullCalendarAsArray, columns: a!forEach( items: local!namesOfDaysInWeek, expression: a!gridColumn( label: left(proper(fv!item), 2), value: a!localVariables( local!dayData: index( fv!row, fv!item, {} ), local!dayInMonth: index( local!dayData, "dayNumberInMonth", {} ), local!isInThisMonth: toboolean( index( local!dayData, "inThisMonth", {} ) ), a!richTextDisplayField( value: a!richTextItem( text: local!dayInMonth, style: if( local!isInThisMonth, "STRONG", { "PLAIN", "EMPHASIS" } ) ) ) ), align: "CENTER", width: "ICON" ) ), spacing: "DENSE" ), /*Editable grid using a!gridLayout() - Number of items no longer shows at the bottom*/ a!gridLayout( label: concat( text(local!today, "mmmm"), " ", local!year ), headerCells: a!forEach( items: local!namesOfDaysInWeek, expression: a!gridLayoutHeaderCell( label: left(proper(fv!item), 2), align: "CENTER" ) ), columnConfigs: a!forEach( items: local!namesOfDaysInWeek, expression: a!gridLayoutColumnConfig( width: "NARROW" ) ), rows: a!forEach( items: local!fullCalendarAsArray, expression: a!localVariables( local!calendarRowData: fv!item, a!gridRowLayout( contents: { a!forEach( items: local!namesOfDaysInWeek, expression: a!localVariables( local!dayData: index( local!calendarRowData, fv!item, {} ), local!dayInMonth: index( local!dayData, "dayNumberInMonth", {} ), local!isInThisMonth: toboolean( index( local!dayData, "inThisMonth", {} ) ), a!richTextDisplayField( value: a!richTextItem( text: local!dayInMonth, style: if( local!isInThisMonth, "STRONG", { "PLAIN", "EMPHASIS" } ) ), align: "CENTER" ) ) ) } ) ) ), /* data: local!fullCalendarAsArray, columns: a!forEach( items: local!namesOfDaysInWeek, expression: a!gridColumn( label: left(proper(fv!item), 2), value: a!localVariables( local!dayData: index( fv!row, fv!item, {} ), local!dayInMonth: index( local!dayData, "dayNumberInMonth", {} ), local!isInThisMonth: toboolean( index( local!dayData, "inThisMonth", {} ) ), a!richTextDisplayField( value: a!richTextItem( text: local!dayInMonth, style: if( local!isInThisMonth, "STRONG", { "PLAIN", "EMPHASIS" } ) ) ) ), align: "CENTER", width: "ICON" ) ), */ spacing: "DENSE" ), /*Manually created grid using columns and card layouts - Very customizable! Also if using the calendar day as a link you can use the whole card layout as the button*/ a!localVariables( local!headerColor: "#1d3557", local!inMonthColor: "#a8dadc", local!outOfMonthColor: "#f1faee", { a!richTextDisplayField( labelPosition: "COLLAPSED", value: a!richTextItem( text: concat( text(local!today, "mmmm"), " ", local!year ), style: "STRONG" ), align: "CENTER" ), a!columnsLayout( columns: { a!forEach( items: local!namesOfDaysInWeek, expression: a!localVariables( local!labelOfColumn: fv!item, local!columnContents: index( local!fullCalendarAsArray, local!labelOfColumn, {} ), a!columnLayout( contents: { a!cardLayout( contents: { a!richTextDisplayField( labelPosition: "COLLAPSED", value: a!richTextItem( text: left(proper(local!labelOfColumn), 2), style: "STRONG" ), align: "CENTER" ) }, shape: "ROUNDED", marginBelow: "EVEN_LESS", style: local!headerColor ), a!forEach( items: local!columnContents, expression: a!localVariables( local!dayData: fv!item, local!dayInMonth: index( local!dayData, "dayNumberInMonth", {} ), local!isInThisMonth: toboolean( index( local!dayData, "inThisMonth", {} ) ), a!cardLayout( contents: { a!richTextDisplayField( labelPosition: "COLLAPSED", value: a!richTextItem( text: local!dayInMonth, style: if( local!isInThisMonth, "STRONG", { "PLAIN", "EMPHASIS" } ) ), align: "CENTER" ) }, shape: "ROUNDED", marginBelow: "EVEN_LESS", style: if( local!isInThisMonth, local!inMonthColor, local!outOfMonthColor ) ) ) ) }, width: "NARROW" ) ) ) }, spacing: "DENSE" ) } ) } )
send the code plz
Hi @ajhick
May I know what is the content of rule!CMN_IsEmpty(local!fullCalendarListOfDays) in line 128.
thank you very much
Sunny Yong said:Hi @ajhick May I know what is the content of rule!CMN_IsEmpty(local!fullCalendarListOfDays) in line 128. thank you very much
Note, this is an older thread so you may not receive a response from the initial participants.
However, I would guess that this is a simple empty check, hence the 0 return if so. Try rule!APN_isEmpty() instead.
Chris said:Try rule!APN_isEmpty() instead.
or these days, a!isNullOrEmpty() will usually be sufficient.
Mike Schmitt said:or these days, a!isNullOrEmpty() will usually be sufficient.
For anyone on 21.4+, yep!
..we gotta get this upgrade rolling.