Dynamically setting View Query

rss

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 Kozlov
    Dmitry Kozlov
    Admin
    Member for: 10 years 4 days
    #1 by Dmitry Kozlov Jan 19 ’15 at 08:13

    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_C
    Member
    Member for: 8 years 9 months 30 days
    #2 by Dan_C Jul 15 ’16 at 10:09

    [#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 Kozlov
    Dmitry Kozlov
    Admin
    Member for: 10 years 4 days
    #3 by Dmitry Kozlov Jul 17 ’16 at 06:23

    [#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_C
    Member
    Member for: 8 years 9 months 30 days
    #4 by Dan_C Aug 31 ’16 at 05:34

    [#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 Kozlov
    Dmitry Kozlov
    Admin
    Member for: 10 years 4 days
    #5 by Dmitry Kozlov Sep 1 ’16 at 03:57

    [#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:

    http://sharepoint.stackexchange.com/questions/145394/view-filtering-on-sharepoint-2013-dynamically-build-query-string

  • Dan_C
    Member
    Member for: 8 years 9 months 30 days
    #6 by Dan_C Sep 1 ’16 at 09:43

    [#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 Kozlov
    Dmitry Kozlov
    Admin
    Member for: 10 years 4 days
    #7 by Dmitry Kozlov Sep 1 ’16 at 09:45

    [#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.

  • DanLash
    Member
    Member for: 2 years 6 months 28 days
    #8 by DanLash Feb 28 ’21 at 01:03

    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

  • DanLash
    Member
    Member for: 2 years 6 months 28 days
    #9 by DanLash Feb 28 ’21 at 01:04

    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

  • rayporter
    Member
    Member for: 2 years 6 months 18 days
    #10 by rayporter Mar 10 ’21 at 02:01

    I can't modify the View dynamically.

    run 3

Displaying 1 to 10 of 15 messages
Previous12