Dynamically setting View Query
Posted by mac_xpert - Jan 16 ’15 at 05:21
Hi I'm using your Related items Lookup on a large list of contacts. Each contact in the list has an associated project. Im trying to lookup the contacts associated with a project.
This works fine for lists of less than 5000 items but on large lists i get no results.
My thought is that if i could in someway dynamically set the Query used in the view of this lookup to match the project name in the form to the project name in the list it would dynamically create a view of less then 5000 items and the related items lookup would work.
I can view the code of the view in SPForms Designer under Extended>View:
<View>
<ViewFields>
<FieldRef Name="Edit" />
<FieldRef Name="Title1" />
<FieldRef Name="FirstName" />
<FieldRef Name="LastName" />
<FieldRef Name="JobTitle" />
<FieldRef Name="ol_Department" />
<FieldRef Name="CompanyLookup" />
<FieldRef Name="ClientOffice" />
<FieldRef Name="Created" />
<FieldRef Name="Modified" />
</ViewFields>
<ViewData />
<Query>
<Where>
<Eq>
<FieldRef Name="FirstName" />
<Value Type="Text">Matthew</Value>
</Eq>
</Where>
</Query>
<Aggregations Value="Off" />
<RowLimit Paged="TRUE">30</RowLimit>
<Mobile MobileItemLimit="3" />
<Toolbar Type="Standard" />
<XslLink Default="TRUE">main.xsl</XslLink>
<JSLink>clienttemplates.js</JSLink>
</View>
But is it possible to change the value of <Value Type="Text">Matthew</Value> in the query to match the content of a field in the form?
Thanks for your help.
Matt.
-
Dmitry KozlovAdminMember for: 10 years 4 days
Unfortunately, you cannot modify the View dynamically. So, i'd recommend you to create an index for the field by which you're going to filter the list or split it into multiple lists with less than 5000 items.
-
Dan_CMemberMember for: 8 years 9 months 30 days
[#1]: Is there still no way to do this? It would be great if we could use a field to add to the filter of the view query.
How does the "filter by field" work in Forms Designer related items?
Is it accurate that "Related Items" using view returning more than 5,000 items but with an indexed field in the Forms Designer "filter by field" will not encounter the 5,000 item threshold error (so long as the filtered result is less than 5k items)?
-
Dmitry KozlovAdminMember for: 10 years 4 days
[#2]: Hi,
How does the "filter by field" work in Forms Designer related items?
Forms Designer creates a connection between web parts. Unfortunately, the connection cannot be set up if a view contains more than 5k items. So, first you need to define a static CAML that returns less than 5k items and then configure the connection. Say, you can filter items by date and include only those created within last month or year.
-
Dan_CMemberMember for: 8 years 9 months 30 days
[#3]: Perhaps someday you could programatically add in part of the "static" CAML query? That way if we have an indexed field relating to the ID of the current item we could choose that field and it would become part of the actual CAML query for the view?
In the meantime, I'm doing like you said and have a view with a -365 day offset... but that won't work if anyone wants to look at an item that's over a year old and expect to see the related items.
-
Dmitry KozlovAdminMember for: 10 years 4 days
[#4]: You can filter the Related Items control by ID of the parent item using the ID parameter from query string. See the first reply in the thread:
-
Dan_CMemberMember for: 8 years 9 months 30 days
[#5]:
Nice. So ... does this eliminate the 5000 limit so long as there aren't 5000 items sharing the shared id? Or does the selected "data source" still have some impact even though the "view" is customized?
-
Dmitry KozlovAdminMember for: 10 years 4 days
[#6]: If the result view contains less than 5k items, everything will work fine. Please, note that the field that you use in the CAML-query must be indexed.
-
DanLashMemberMember for: 2 years 6 months 28 days
Programming is a complicated thing. If you want to learn it, there are several ways: on your own and enroll in some courses.It is very difficult to learn it on your own, and the courses cost money. To find a job, you can use our service best cv
-
DanLashMemberMember for: 2 years 6 months 28 days
Programming is a complicated thing. If you want to learn it, there are several ways: on your own and enroll in some courses.It is very difficult to learn it on your own, and the courses cost money. To find a job, you can use our service www.topcvservices.co.uk
-
rayporterMemberMember for: 2 years 6 months 18 days
I can't modify the View dynamically.