Solved

K2 Designer how do you auto generate consecutive dates on new colums

  • 18 March 2022
  • 4 replies
  • 81 views

Hello . I'm new to K2, and one of my assignments requires me to create a form that will take a user's date selection from one view and auto-generate the next 5 dates on another view. I was also curious if this could be done on an item view rather than just an editable list View which is what i am using.

 

I'm fine with the other parts of the view, but it's the transfer of data (the date from view 1) from one view to the other (view 2) and then generating the other 5 dates that I'm having trouble with. I've tried different rules, but I can't get the date to display or generate in the next few columns.

 

 
I'm just looking for clarification on how to do this; perhaps I need to first create a SQL database and then associate it with the smartobject with the sql of date generation alreaded embedded because I'm not sure at the moment.

 

 

icon

Best answer by AMolyneux 18 March 2022, 15:31

View original

4 replies

Userlevel 3
Badge +9

Hi there,


 


You can probably do it with a list view out of the box but as you say it may be easier to take the first date as an input to a stored procedure and then generate the 5 rows for the list view and load the list view with those rows populated for the date but not the rest of the information.


 


That would be the most flexible - however if it is always going to be just 5 dates then you could indeed use an item view - something like this:



 


Then pass through the start date as a parameter to it:



 


Then have a set of expressions to calculate the days for the data labels:


 



 


And then save those values back, along with the inputs from the text boxes:


 



Cheers

This will probably be easier to do using a single item view than with an item view and a list view.



  1. Create the item view with all the controls you need as per the “View layout” screenshot

  2. For each of the generated date controls, create an expression using the “Add Days” function that takes the date you select in the calendar control and add the necessary number of days. See the “Expression” screenshot

  3. Set the Format for each of the generated date controls to the date format you want. See “Set date format” screenshot.

  4. This will then generate the 5 consecutive dates you need. See “Working view” screenshot

  5. Use expressions to calculate the total working days for the week etc.

Paul, thank you very much. I'm quite grateful; I'd been trying for a long time, studying for a solution, so this means a lot to me. It works perfectly.

I decided to proceed with this, thank you so much, I had been hesitant about forums because I was afraid of being judged for asking what some would consider "dumb questions" or being part of a negative group, but the speed of the replies and advice meant a lot to me because I am new to k2. Thank you one again.

Reply