Multiple lookups on related items - Problems

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
User avatar
Roo
Posts: 107
Joined: Tue Oct 24, 2017

08 Oct 2018

I've got 3 questions/Problems with related items.

I have a parent form that has a lookup field (Employee name) and a Recorded date (the date is set to today)
I have a related item (child) which points to a document library file. In the child library I also have a Employee Name and a Recorded Date field.

Problem 1. When I drag a new document into the form the date format in the child library is in US:

Image

Problem 2
I want to create two filters form the related items and have used some of the code shown previously in the forums

//first filter on page load
setHash();

fd.updateDroppedDocuments($('.SCForm'), function(listItem) {
//get the values from the Form fields:
var employee = fd.field("Employee_x0020_Name").control('data')['Employee_x0020_Name'];
var rdate = fd.field("RecordedDate").value();
//set the values on uploaded document:
listItem.set_item('Employee_x0020_Name', employee);
listItem.set_item('RecordedDate', rdate);
listItem.update();
});



//and attach an on-change handler that will call the filtering function wherever the value of the field changes
fd.field('Employee_x0020_Name').change(setHash);
fd.field('RecordedDate').change(setHash);

//this is the actual function that filters the list
function setHash(){
//get value
var value = fd.field('Employee_x0020_Name').value();
if (!value) {
value = "";
}

var value2 = fd.field('RecordedDate').value();
if (!value2) {
value2 = "";
}

value = encodeURIComponent(escape(value)).replace(/\-/g, "%252D");
value2 = encodeURIComponent(escape(value2)).replace(/\-/g, "%252D");

//set the URL’s hash value. An explanation on this is at the end of the article.
window.location.hash = "InplviewHash" + $(".SCForm [webpartid]").attr("webpartid") + '=FilterField1=Employee_x0020_Name-FilterValue1=' + value + '-FilterField2=RecordedDate-FilterValue2=' + value2;
}


I can't seem to get this working - I've manually changed the date as shown in problem 1 - so it doesn't seem to be this causing the problem.

Problem 3
When I remove all the JS on the form and just have a basic filter - the related items are still not showing. for some reason I have a strage filter showing it I manually try and change it:

Image
Attachments
attachment 2.jpg
attachment 2.jpg (52.42 KiB) Viewed 3378 times
attachment 1.jpg
attachment 1.jpg (50.3 KiB) Viewed 3378 times

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

09 Oct 2018

Hi Roo,

OK, let's go through the issues:

1) Site Settings -> Regional Setting -> Locale. The datepicker will be in an appropriate format after changing.

2) Try to use another approach like this (concatenating filter URL another way):

Code: Select all

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

function setHash2(){
var hash = window.location.hash;
var value =  encodeURIComponent(escape(fd.field('Choice').value())).replace(/\-/g, "%252D");
window.location.hash = hash + "#InplviewHash" + $(".related-docs [webpartid]").attr("webpartid") + '=FilterField=Text-FilterValue=' + value;
}
3) It seems like something wrong with a static filter in the datasource. Please turn it off and try again. After that turn it on again. If this is doesn't help, please provide the screenshot of the browser console, the URL and the filter settings.

User avatar
Roo
Posts: 107
Joined: Tue Oct 24, 2017

10 Oct 2018

Thanks for your reply
Number 1.
I can confirm that this subsite and the mainsite has UK regional settings:
atta2.jpg
atta2.jpg (13.15 KiB) Viewed 3366 times
and that when dropping the form in it still converts it in US.
atta1.jpg
atta1.jpg (44.19 KiB) Viewed 3366 times
Number 2
I tried this, but it is still not filtering on both fields. It doesn't seem to like the filtering on the Employee_name. As mentioned this field is a cross-site look up on the primary site not the subsite.
Also I don't really want it on field change, rather just to display or to update when a document is dragged into the form as with other forms.

Number 3
What I have done is I have got rid of the employee name data source filter and replaced it with the recorded date.

What may be the easiest solution to all of these is - Is is Possible to link the Form Unique ID to a field on the related document library. (ie called masterformID) if so how would this be done as the ID field is not should in form designer? if this can be done what would the related item column format need to be. This would be an ideal solution as it would by-pass the date problem and the lookup problem?

User avatar
Roo
Posts: 107
Joined: Tue Oct 24, 2017

10 Oct 2018

Hi Alex

I've used this to solve the issue:

fd.updateDroppedDocuments($('.SCForm'), function(listItem) {
//get the values from the Form fields:
var fid = parseInt(window.top.GetUrlKeyValue('ID'));
//set the values on uploaded document:
listItem.set_item('Title', fid);
listItem.update();
});


One last question - Is the a way within the update dropped item to rename the file itself? in my case as Sting of ParentID + Employee_x0020_Name + RecordedDate. But keeping the extention in tact?

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

10 Oct 2018

Hi Roo,

I'm very happy you have found a solution, I still can't reproduce your date and filter issue on my site.

Check this article about related documents (a renaming is included): https://spform.com/javascript-framework ... ctionality. Please feel free to ask if you will have any questions.

User avatar
Roo
Posts: 107
Joined: Tue Oct 24, 2017

10 Oct 2018

Everything is working now except the date is still changing the date to US format! and I can't see a way of preserving the extension (ie DOCX or TXT or PDF)

Thanks
attb1.jpg
attb1.jpg (96.33 KiB) Viewed 3353 times

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

12 Oct 2018

Hi Roo,

Honestly, I don't know yet, why you have a date issue in related items. Could you check a regular list view of that list to be sure that this is an issue of the related items only?

About preserving an extension: viewtopic.php?f=1&t=2238

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 18 guests