Related items filter issue

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
jimhugelier
Posts: 9
Joined: Thu Mar 23, 2017

25 Apr 2017

Hi,

My situation is as follows: I have a new item form on a list called 'Test Tasks'. In this list, I can select a 'Project', which is a lookup field to a list called 'Projects'. What I am trying to achieve is selecting a project from the dropdown and automatically filtering a related items control bound to this field.

I have set the related items control settings to:
  • List : Projects
  • View : All items
  • Filter by: form field
  • Form field: Project (internal name = Project)
  • List field: Title (internal name = Title)
  • Render: Client
  • Css class: relatedProjectInfo
My javascript is as follows:

Code: Select all

setHash();
fd.field('Project').change(setHash);
 
function setHash(){
var value =  encodeURIComponent(escape(fd.field('Project').value())).replace(/\-/g, "%252D");
window.location.hash = "InplviewHash" + $(".relatedProjectInfo [webpartid]").attr("webpartid") + '=FilterField=Title-FilterValue=' + value;
When I change the project, the javascript triggers the event handler just fine. When I check the hash value, this seems to be correct as well. However when I continue, I noticed in my request URL that I am suddenly passing this:
https://dcp.skyline.be/_layouts/15/inpl ... terValue1=

The filter value was cut off somewhere. I'm not sure what else to do to try and solve this, so I came here for help.

Kind regards,

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

26 Apr 2017

fd.field('Project').value() code returns ID of the selected item whereas you need a title. Please, try this:

Code: Select all

setHash();
fd.field('Project').change(setHash);
 
function setHash(){
var value =  encodeURIComponent(escape(fd.field('Project').control('getSelectedText'))).replace(/\-/g, "%252D");
window.location.hash = "InplviewHash" + $(".relatedProjectInfo [webpartid]").attr("webpartid") + '=FilterField=Title-FilterValue=' + value;

jimhugelier
Posts: 9
Joined: Thu Mar 23, 2017

26 Apr 2017

Hi Dmitry,

Thanks for the swift feedback. I am still, however, experiencing the same issue after changing the the aforementioned code. When I debug, the value in my window.location.hash is the following:

#InplviewHash5f5a9ab2-e3b4-4dc8-b61f-4a88ab23cbe2=FilterField=Title-FilterValue=TLN%252DFC25572%252D160915%252DExtra%2520Drivers%2520for%2520HE

, while the project is called: TLN-FC25572-160915-Extra Drivers for HE.

So the hash does seem to be correct at first glance..

P.S.: if I try to surf to the url with the hash included directly, I see in my Sharepoint logs the following error:
'JSON data retrieval operations are disallowed on HTTP GET requests' and '403 Forbidden will be returned'.

Kind regards,

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

27 Apr 2017

Hi,
Try to remove escaping from your code:

Code: Select all

var value =  fd.field('Project').control('getSelectedText');
window.location.hash = "InplviewHash" + $(".relatedProjectInfo [webpartid]").attr("webpartid") + '=FilterField=Title-FilterValue=' + value;
If it does not help, filter the Related Items manually by clicking the Project header and picking an arbitrary value. Compare the hashes: one that is generated in your code and another that is added by SharePoint after manual filtering.

jimhugelier
Posts: 9
Joined: Thu Mar 23, 2017

27 Apr 2017

Hi Dmitry,

Thanks for the tips. I did as you said and tried without escaping but that didn't work out.

The hash when I manually put an arbitrary filter on it is as follows:
"https://dcp.skyline.be/_layouts/15/inplview.aspx?List={735D80A9-034F-4213-AE42-1B81DCB4A909}&View={D51C04EF-498E-4682-A7C2-1EDCF253CDCD}&ViewCount=6&IsXslView=TRUE&IsCSR=TRUE&RootFolder=&IsDlg=1&Web=63eb9fcf-0525-4767-9df3-5fa1aec5d97f&FilterField1=Status&FilterValue1=In%20Progress"

while the hash I seem to send (debugged from inplview.js-file) is:
"https://dcp.skyline.be/_layouts/15/inplview.aspx?List={735D80A9-034F-4213-AE42-1B81DCB4A909}&View={D91254C2-B8EA-46D1-ABB8-6EBCDE3781C9}&ViewCount=15&IsXslView=TRUE&IsCSR=TRUE&FilterField1=Title&FilterValue1="

Notice I did not change my filter away from Project title (I don't think it would make a difference if I filtered on status instead). Apart from my value being cut off, I also notice I don't have the 'RootFolder, IsDlg and Web' parts either.

Any thoughts?

P.S.: when debugging, if I step through everything happening after the window.location.hash is set, it goes through plumsail.fd.jquery, a ScriptResource file, an init.js-file and finally the moment it enters the inplview.js file, the filtervalue is cut off. Before that, I checked and every step of the way, the value stayed intact.

jimhugelier
Posts: 9
Joined: Thu Mar 23, 2017

02 May 2017

Hi,

Just following up. Any thoughts yet?

Kind regards,

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

03 May 2017

Hi,
As I said, please, filter the view manually by the Title field in the form: click the column header and pick some value from the drop-down. Then copy the URL hash (right from the browser's command line), it will be like this:
#InplviewHash5f5a9ab2-e3b4-4dc8-b61f-4a88ab23cbe2=FilterField=Title-FilterValue=SomeValue

Then switch the 'Project' field to the same value and copy the URL hash again. Compare both hashes.

jimhugelier
Posts: 9
Joined: Thu Mar 23, 2017

03 May 2017

Hi Dmitry,

Thanks for all your advice. I have found, for some weird reason, that if I do not set the related items control to 'filter by form field' but just 'show all items' that it works (the javascript part stayed the same)! It now correctly filters by the project I selected, with the javascript I have set.

P.S.: related to this, do you have any idea if there is an event I could use for when the related items control values have changed. I have to wait until they are changed to copy some values to other fields.

Thanks again,

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

04 May 2017

Hi,
Unfortunately, I cannot provide a sample since it may take a lot of time on researching JavaScript sources of the SharePoint grid view. I'd recommend you to send the detailed requirements with screenshots to support@spform.com and our support team will estimate them.

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 6 guests