GetValuesForQuery
AnsweredI have two lists, one contains salaries and the other contains tax rates that are applicable depending on the salary.
The 3 columns that I am concerned with are as follows:
Salary ---> Number (Salary List)
MinimumSalary ----> Number (Tax List)
MaximumSalary ----> Number (Tax List)
Tax Rate ------> Number (Tax List)
Tax Amount ---------> Number (Tax List)
The Minimum and Maximum Values on the Tax List are as follows:
Min Max
0 18000
18001 37000
37001 80000
80001 180000
180001 750000
This is the query I am using:
var x = [[@Web.GetValuesForQuery('REF-TAX-RATES','<Query><Where><And><Geq><FieldRef Name="MinimumSalary" /><Value Type="Number">[[SalaryPackageValueFT]]</Value></Geq><Leq><FieldRef Name="MaximumSalary" /><Value Type="Number">[[SalaryPackageValueFT]]</Value></Leq></And></Where></Query>', 'MaximumSalary')]];
When I use a Salary = 50000, I get a null returned.
If I use this query:
var x = [[@Web.GetValuesForQuery('REF-TAX-RATES','<Query><Where><Geq><FieldRef Name="MinimumSalary" /><Value Type="Number">[[SalaryPackageValueFT]]</Value></Geq></Where></Query>', 'MaximumSalary')]];
I only get the 80001 -----180000 and 180001 ----- 750000 information returned
With the first query I would have expected to get the 37001 -------- 80000 row returned and for the second one I would have expected to get the 37001 ---- 80000, 80001 -----180000 and 180001 ----- 750000 rows returned.
Ideally I would be able to return all of the columns on the Tax List row.
Any help you can provide on this would be appreciated or any alternative suggestions. I also saw the QueryList command and would appreciate an example of how this would look with my example above.
Thanks
Sandy
-
I think you have to exchange the LEQ and GEQ parts of your query. You see what the issue is in your second query that Returns some values (but the wrong ones). What you are asking SharePoint is to give you the values of the list where "MinimumSalary" is greater or equal to 50000. You want it to give you results that are lower or equal. So you have to exchange the criteria parts in your first query and it should work.
0
Please sign in to leave a comment.
Comments
1 comment