Is it possible to refresh a related items control programmatically

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
andyb
Posts: 25
Joined: Fri Oct 26, 2018

12 Nov 2018

I have some code which creates a word document, updates the lookup field so that it is related to the parent (edit) form. Once created, I can trigger the form to reload using window.location.reload(), however I'd like to be able to update the related items webpart only.

Is this possible?

Kind regards
Andy

User avatar
AlexZver
Posts: 232
Joined: Mon Aug 27, 2018

13 Nov 2018

Dear Andy,

Please check this code:

Code: Select all

fd.relatedItems(0).data('ctx').clvp.RefreshPagingEx('');

andyb
Posts: 25
Joined: Fri Oct 26, 2018

23 Nov 2018

Thanks Alex, does this also work in related items that are Document Libraries? I have 7 related items controls in my form and am struggling to work out which is which :)

Andy

User avatar
AlexZver
Posts: 232
Joined: Mon Aug 27, 2018

26 Nov 2018

Hi Andy!

Yes, it works. You can call "fd.relatedItems(index).data('ctx').clvp.RefreshPagingEx('');" one by one incrementing a zero-based index in the browser console to figure out the order of the related items on your form.

andyb
Posts: 25
Joined: Fri Oct 26, 2018

04 Dec 2018

Hi Alex, thanks for confirming, I eventually figured out the order of the controls I needed to refresh - however I seem to have found an issue - I have one related item control that is using a caml query to filter the results:

<Toolbar Type="None" />
<ViewFields>
<FieldRef Name="Remove" DisplayName="Remove"></FieldRef>
<FieldRef Name="ChangeDetails" DisplayName="Edit Details"></FieldRef>
<FieldRef Name="DBClientLookup" DisplayName="Client Name"></FieldRef>
<FieldRef Name="ClientType" DisplayName="Client Type"></FieldRef>
</ViewFields>
<Query>
<Where>
<Eq>
<FieldRef Name="RelatedMatterLookup" LookupId="TRUE" />
<Value Type="Lookup">{ID}</Value>
</Eq>
</Where>
<OrderBy>
<FieldRef Name="ID"></FieldRef>
</OrderBy>
</Query>
<ParameterBindings>
<ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
<ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
<ParameterBinding Name="ID" Location="QueryString(ID)" />
</ParameterBindings>
</View>

It gets the ID from the querystring and passes that as 'ID' in the CAML query - note this is the only related item control on the form that uses the above schema.. when I refresh this control using the code above I get 'no results' in my related items.

Do you know why this might be happening? The CAML is there because the originating list is over 5000 items and this was the only way to make the control 'viewable'.

andyb
Posts: 25
Joined: Fri Oct 26, 2018

22 Feb 2019

I know this is an old post, but any news on this? The refresh seems to work, but the resulting list/library is not rendered. Still seems to be the case when I try using it on CAML filtered libraries.

User avatar
AlexZver
Posts: 232
Joined: Mon Aug 27, 2018

28 Feb 2019

Hi Andy,

I'm sorry for a late reply, I've accidentally missed this topic. We are working on your issue.

User avatar
AlexZver
Posts: 232
Joined: Mon Aug 27, 2018

28 Feb 2019

Could you please clarify in what place of the code/Designer you've specified the CAML query for the Related Items?

andyb
Posts: 25
Joined: Fri Oct 26, 2018

28 Feb 2019

Yep, I've put it in the View section for the related items control within Forms Designer. I've modified it a little since this original post, so I'll repost the xml here:

<View>
<XslLink>main.xsl</XslLink>
<JSLink>clienttemplates.js</JSLink>
<Query>
<Where>
<Eq>
<FieldRef Name="RelatedMatterLookup" LookupId="TRUE" />
<Value Type="Lookup">{ID}</Value>
</Eq>
</Where>
<OrderBy>
<FieldRef Name="ID"></FieldRef>
</OrderBy>
</Query>
<ViewFields>
<FieldRef Name="Remove" DisplayName="Remove"></FieldRef>
<FieldRef Name="ChangeDetails" DisplayName="ChangeDetails"></FieldRef>
<FieldRef Name="DBClientLookup" DisplayName="DBClientLookup"></FieldRef>
<FieldRef Name="ClientType" DisplayName="ClientType"></FieldRef>
</ViewFields>
<RowLimit Paged="TRUE">30</RowLimit>
<Aggregations Value="Off" />
<Toolbar Type="None" />
<ParameterBindings>
<ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
<ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
<ParameterBinding Name="ID" Location="QueryString(ID)" DefaultValue="0" />
</ParameterBindings>
</View>

Note, for this to work as a filter the Related Items data source settings are All Items view, with 'Show all items from the view' selected. It didn't appear to work when I put a filter there as well as in the xml. Hope that helps.

User avatar
AlexZver
Posts: 232
Joined: Mon Aug 27, 2018

01 Mar 2019

Dear Andy,

Thank you for the details, we are working on your issue.

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 16 guests