Page 1 of 2
Is it possible to refresh a related items control programmatically
Posted: 12 Nov 2018
by andyb
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
Re: Is it possible to refresh a related items control programmatically
Posted: 13 Nov 2018
by AlexZver
Dear Andy,
Please check this code:
Code: Select all
fd.relatedItems(0).data('ctx').clvp.RefreshPagingEx('');
Re: Is it possible to refresh a related items control programmatically
Posted: 23 Nov 2018
by andyb
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
Re: Is it possible to refresh a related items control programmatically
Posted: 26 Nov 2018
by AlexZver
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.
Re: Is it possible to refresh a related items control programmatically
Posted: 04 Dec 2018
by andyb
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'.
Re: Is it possible to refresh a related items control programmatically
Posted: 22 Feb 2019
by andyb
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.
Re: Is it possible to refresh a related items control programmatically
Posted: 28 Feb 2019
by AlexZver
Hi Andy,
I'm sorry for a late reply, I've accidentally missed this topic. We are working on your issue.
Re: Is it possible to refresh a related items control programmatically
Posted: 28 Feb 2019
by AlexZver
Could you please clarify in what place of the code/Designer you've specified the CAML query for the Related Items?
Re: Is it possible to refresh a related items control programmatically
Posted: 28 Feb 2019
by andyb
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.
Re: Is it possible to refresh a related items control programmatically
Posted: 01 Mar 2019
by AlexZver
Dear Andy,
Thank you for the details, we are working on your issue.