February 10, 2012  
   Login  
Forum  
 
ForumForumEnesys RS Data ...Enesys RS Data ...Support - RS Da...Support - RS Da...Handling Optional (Null) ParamatersHandling Optional (Null) Paramaters
Previous Previous
 
Next Next
New Post
 3/23/2007 4:32 AM
 

I would like to have a report parameter that is optional and have the query react differently based on whether the parameter use used or not.

For example, say I have several "Category" values.  I set up a dataset to return the distinct Categories from my data and use that as the values the user can choose for the "cat" report parameter.  I want the report user to either specify a category, or keep the parameter null to indicate that all categories should be returned.

My CAML might look something like:

<list title="Products" relativeSiteUrl="/sites/demo" tableName="Products">
   <fields>Title, Category, Supplier, UnitPrice</fields>
   <query>
      <Where>
         <Or>
            <Eq>
               <FieldRef Name="Category" />
               <Value Type="Text">@cat!</Value>
            </Eq>
            <IsNull>@cat!</IsNull>
         </Or>
      </Where>
   </query>
</list>

As you might expect, this does not work.  I basically want to make sure I only retrieve the category the users chooses, or retrieve all of the categories if the user wants to see them all (by specifying null for the parameter).

Any suggestions?  This seems to be a theme throughout some of my reports.

Thanks,
Kirk
www.threewill.com
www.worktogetherbetter.com

New Post
 3/23/2007 1:16 PM
 
Hi,
Unfortunately this is not possible using CAML query language unless we add some syntactic trick that would change the caml query under the hood.
You're best option at the moment is to retrieve all items from the list and to filter at the report level.
Does this makes sense?
Please let me know if you need more help.
Regards,

Frederic LATOUR
ENESYS
New Post
 3/23/2007 3:18 PM
 
A coworker of mine recommended the same solution which works well.  For optional parameters this solution is fine.

Thanks,
Kirk
Previous Previous
 
Next Next
ForumForumEnesys RS Data ...Enesys RS Data ...Support - RS Da...Support - RS Da...Handling Optional (Null) ParamatersHandling Optional (Null) Paramaters

 
You need to login for posting to the forums.
If you don't have a login, click here to register.
 
Copyright 2010 Enesys - All rights reserved Terms Of UsePrivacy Statement