Click here to Skip to main content
16,016,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i have the following query on a table that has a level, and within each level has sub levels- I want to find any records that are infront of the users level/sublevel. To this i want to find all records that:

(Belong to the employee) AND (<has a="" greater="" level="">  OR <{has a level equal} AND has a greater sublevl}>)</has>


This is my current query: however it returns records that dont even belong to the user entered(Problem with use of the <or>?)

<where>                                             
   <and>
      <eq>
        <fieldref name="AssignedTo" />
        <value type="User">
        <userid />
        </value>
      </eq>   
      <or>
         <gt>
         <fieldref name="Skill_x002d_Set_x0020_Level" />
         <value type="Lookup">"+strEmpsSkillLvl+@"</value>
         </gt>
         <and>
                                                            
           <eq>
           <fieldref name="Skill_x002d_Set_x0020_Level" />
          <value type="Lookup">"+strEmpsSkillLvl+@"</value>
           </eq>
                                              
          <geq>
           <fieldref name="Station_x0020_Number" />
           <value type="Number">"+strEmpsStationNumber+@"</value>
          </geq>
          </and>
       </or>
     </and>
   </where>




*EDIT

XML
Yes list*

also by levels i'm refering to the data
I have a set of record of skills

with levels and parts ie:
    -Level1
     -part1
     -part2
     -part3
    -Level1
     -part1
     -part2
     -part3.

Also I have used CAML builder - however I seemed to have some issues getting the or encompassing the correct elements from what I have seen

Builder gives me the following which returns the wrong information still:
<pre><query>
                                            <where>
                                             <and>
                                              <eq>
                                                 <fieldref name="AssignedTo" />
                                                  <value type="User"><userid /></value>
                                              </eq>
                                              <or>
                                                <and>
                                                    <eq>
                                                        <fieldref name="Skill_x002d_Set_x0020_Level" />
                                                         <value type="Lookup">"+strEmpsSkillLvl+@"</value>
                                                    </eq>
                                                     <gt>
                                                        <fieldref name="Station_x0020_Number" />
                                                        <value type="Number">"+strEmpsStationNumber+@"</value>
                                                     </gt>
                                                </and>
                                                <gt>
                                                    <fieldref name="Skill_x002d_Set_x0020_Level" />
                                                    <value type="Lookup">" + strEmpsSkillLvl + @"</value>
                                                </gt>
                                              </or>
                                            </and>
                                            </where>
                                            <orderby>
                                            <fieldref name="Skill_x002d_Set_x0020_Level" ascending="True" />
                                            <fieldref name="Station_x0020_Number" ascending="True" />
                                            <fieldref name="Status" ascending="True" />
                                            </orderby></query>


(also debugging shows the strings do contain the right values.
Posted
Updated 17-Nov-11 3:25am
v3
Comments
[no name] 17-Nov-11 7:22am    
By table I'll assume you mean list since there are no tables in SharePoint. What do you mean by "level"?
Craig_ 17-Nov-11 9:01am    
EDITED. Many problems? any chance you could elabourate?
Craig_ 17-Nov-11 9:13am    
Seemed to have an old version of U2U CAML, new version looks a lot better will try this.

Try using a tool such as CAML Builder[^] to assist you in building the CAML. This will show you what is wrong (many things) with this query
 
Share this answer
 
Partly my query i think- feel a bit stupid now(left the <query> tags in my code)

Thanks for that link though mark!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900