How to query a sublibrary recursively?
AnsweredHi,
I am currently working on a validation where I have to check whether a certain field (yes/no) is set to yes in a subLIBRARY.
I am using the querylist function and have setup the following function:
var evidence = [[@Web.QueryList('RiskAttachments', '<Where><And><Eq><FieldRef Name="Link_Control"/><Value Type="Lookup">[[ControlNr]]</Value></Eq><Eq><FieldRef Name="isEvidence"/><Value Type="Boolean">Yes</Value></Eq></And></Where>', 100, 'ID', 'Scope=\"Recursive\"')]];
When I execute the code above it runs but does not return any result. I expect one returned row. I have checked the same CAML query in other tooling and then it return my desired result.
I use as variable in the query the [[ControlNr]]. Even when I pass the value hardcoded is returns an empty result.
(my variable evidence is empty).
I assume that my attribute (Scope = recursice) does not work / isn't working.
Due to the fact that SkyBow RichForms stores documents in sublibraries in folders I expect that I have to query the library recursively.
How to perform a recursive query on the library? Or any other ideas to check for a value in a library?
Any help would be heavily appreciated.
-
There are two things in your caml to fix and you're right, there is an additional issue in the viewAttribute for recursive scope definiton.
Filter for lookups:
You have to use the attribute LookupId on your FieldRef if you want to check the lookup by ID.
<Eq>
<FieldRef Name="Link_Control" LookupId="TRUE" />
<Value Type="Lookup">10</Value>
</Eq>Filter for booleans:
Boolean values are 0 and 1 in CAML of QueryList, not Yes and No.
<Eq>
<FieldRef Name="isEvidence" /><Value Type="Boolean">1</Value>
</Eq>viewAttributes (scope):
You don't have to use these extra escape characters (\) if you don't use same quotes for parameter string and content inside string. So just write this in the end of your expression:
..., 'ID', 'Scope="Recursive"')]];
I hope I get all things to fix.
0 -
Hi Christof Nussbaumer,
Thanks for your reply and solution. I was able to query the sublibrary recursively.KR,
Jelle Dijkstra
0
Please sign in to leave a comment.
Comments
2 comments