Lookup column with date filter
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear Jacob,
This might be part of the problem, but not the critical one, at least the filtering should still work, even if dates do not match. The dates do not match, because of the time difference. When you transform date to ISO format, like we do in the code, it automatically switches timezone from your local one to UTC (aka GMT), that causes time to go over midnight and date to change. This can be fixed, but for now, it's more important to ensure that the filtering works properly.
If you didn't change the name in the Source List, then please correct the code to keep using the original name:
This might be part of the problem, but not the critical one, at least the filtering should still work, even if dates do not match. The dates do not match, because of the time difference. When you transform date to ISO format, like we do in the code, it automatically switches timezone from your local one to UTC (aka GMT), that causes time to go over midnight and date to change. This can be fixed, but for now, it's more important to ensure that the filtering works properly.
If you didn't change the name in the Source List, then please correct the code to keep using the original name:
Code: Select all
function (term, page) {
var vergaderdatum = fd.field('Vergaderdatum').value();
if (vergaderdatum)
vergaderdatum = "Datum_x0020_overleg eq datetime'" + new Date(vergaderdatum).toISOString() + "'";
else
vergaderdatum = '';
if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Datum_x0020_overleg&$filter=" + vergaderdatum + "&$top=10";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby={LookupField},Datum_x0020_overleg&$filter=startswith({LookupField}, '" + encodeURIComponent(term) + "') and " + vergaderdatum + "&$top=10";
}
Cheers
The errors are gone!
I entered a date 1-4-2018 which exists in Agenda. I get the message: No results.
If i enter the date 31-3-2018 which does not exist in Agenda, the search seems to hang and the console gives the following error:
I entered a date 1-4-2018 which exists in Agenda. I get the message: No results.
If i enter the date 31-3-2018 which does not exist in Agenda, the search seems to hang and the console gives the following error:
Code: Select all
jsinitializer.ashx?web=%2Foverleg%2Ftest&list=8050dd86-2d99-432b-9a3a-111158d178b5&field=Agenda_x0020_item&el=cslAgenda_x0020_item&key=csl_init_cslAgenda_x0020_item.js&rev=1521620504828:16 Uncaught RangeError: Invalid time value
at Date.toISOString (<anonymous>)
at Plumsail.CSL.CrossSiteLookup.retrieveItemsUrl (jsinitializer.ashx?web=%2Foverleg%2Ftest&list=8050dd86-2d99-432b-9a3a-111158d178b5&field=Agenda_x0020_item&el=cslAgenda_x0020_item&key=csl_init_cslAgenda_x0020_item.js&rev=1521620504828:16)
at m.fn.init.url (plumsail.csl.crosssitelookup.js:1)
at plumsail.csl.select2.js:22
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear Jacob,
Okay, that is strange. Try to select the same date, get the same result from the Cross-site Lookup and enter the following code into the console:
What will the result look like? Send us a screenshot.
Okay, that is strange. Try to select the same date, get the same result from the Cross-site Lookup and enter the following code into the console:
Code: Select all
var vergaderdatum = fd.field('Vergaderdatum').value();
if (vergaderdatum)
vergaderdatum = "Datum_x0020_overleg eq datetime'" + new Date(vergaderdatum).toISOString() + "'";
else
vergaderdatum = '';
console.log(vergaderdatum);
Cheers
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
No, this is good, I understand that it says "No results." Can you reproduce the actual error you've told me about and then use the same code?
Cheers
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear Jacob,
Okay, I see. Can you tell me if you select the date in the window or manually enter the date? Could it be that month and day are in the wrong spot? Try to enter 3-31-2018 instead.
Okay, I see. Can you tell me if you select the date in the window or manually enter the date? Could it be that month and day are in the wrong spot? Try to enter 3-31-2018 instead.
Cheers
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Okay, I see. Try to run just this command from console when you get this error:
Code: Select all
fd.field('Vergaderdatum').value();
Cheers
Sorry just noticed other format: 3-31-2018 also gives No results found.
If i pick the date 31-3-2018 and run the above console command i get this:
If i pick the date 31-3-2018 and run the above console command i get this:
Code: Select all
fd.field('Vergaderdatum').value();
"31-3-2018"
-
- Information
-
Who is online
Users browsing this forum: No registered users and 8 guests