How to create a query form in K2 Designer with a date range?


  • Anonymous
  • 0 replies

Hi,

 

I've been doing a query in the MS SQL Studio for a weekly report and it become tedious. I've been thinking of creating a form in K2 to run this weekly report.

 

I've created a SmartObject Stored Procedure to produce the worklist in K2 so that it will automatically display the data everytime the form is loaded, but of course it will show the whole data. I would like to create some control on the form where user can select the date range for the data to be displayed.

 

Any guideline or link you can show me? A total K2 newbie here in need of your advice :)

 

Thanks in advance for your assistance. 


4 replies

Badge +15

Hi,


 


If you already have the SQL Stored Procedure created, just create a SmartObject from it.


 


Once you have the SmartObject, go to Designer and create a List view. List view allows you to bind a SmartObject to it, and will generate a table for you. You can add on to that view, by adding two Calendar controls. These two Calendar controls allow you to specify your date range.


 


Then you need to add a rule to execute the View's List method (since the SmartObject is bound to your View, this will also call the SmartObject's List method). In the rule, you can reference the two Calendar controls to be used as input or filter for your SmartObject.


 

Badge +8

boringNerd summed it up, but as someone who was a K2 Newbie, I'll try and add a bit.

 

When you build your stored procedure, ensure you have  parameters for how you want to filter the list.

 

 

So for example, you might have two parameters such as:

 

@ListFrom DATE,

@ListTo DATE

 

Then when you write the query at the bottom of the stored procedure, include those parameters, like maybe:

 

select Name, Task, Date

where date >= @ListFrom and date <= @ListTo

 

When you build your smart object from this stored procedure, the List From and List To parameters will go into the stored procedure, and when you configure the method, you can pass in values from your calendar controls on your form to isolate the data to the range you want.  

 

Hope that helps.

Thanks sir for the suggestion. Will do!

Thanks  @boringNerd and  @Robert_Nicholas for the guidance! I'll do as per advices and will update on the result later

Reply