Looping/Counting items in Related Items
-
- Posts: 18
- Joined: Wed May 17, 2017
Sadly I had to delete and recreate that list along with the forms from a backup I created due to being unable to get the original form/list working properly. I will however see if the issue reoccurs once I have got back to where I was as it is using the same code as before. Shall let you know soon as I can but thank you again.
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
No problem, keep us updated. We would love to know if it resolved the issue and if not, we'll definitely get to the bottom of it.
Cheers
-
- Posts: 18
- Joined: Wed May 17, 2017
OK - I have recreated how it was before and still experiencing the same issue when it comes to counting/looping through relatedItems list. Also it will not load the form correctly in IE or Edge but does still in Firefox for some reason.
Thanks again,
Joss.
In Form Designer looks like:
Let me know if you need any more information though.Thanks again,
Joss.
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Code: Select all
SCRIPT1004: Expected ';'
fd_Item_NewForm.aspx (616, 7)
Click on the error in your browser console and try to find the exact place where the missing semicolon should be.
Cheers
-
- Posts: 18
- Joined: Wed May 17, 2017
I did wonder this too and had a look, however why then would it work in Firefox I wonder?
It is pointing to the first line of a function, which shouldn't have a ; as you can see below:
and in IE Debugger:
I can't see any missing ; there...unless it's an issue with IE/Edge and async functions...
It is pointing to the first line of a function, which shouldn't have a ; as you can see below:
Code: Select all
async function initForm() {
try { var results = await getPON(); }
catch(e) { console.log(JSON.stringify(e)); }
var tmp; var pon = 0;
if (results) {
for (i in results) {
tmp = parseInt(results[i].Title.match(/\d+/)[0],[10]);
if (tmp > pon) { pon = tmp; }
}
pon += 1;
pon = 'TD' + pon;
console.log('PO: ' + pon);
fd.field('Title').value(pon);
fd.populateFieldsInGrid($('.related-items'), {
Title: pon,
});
cleanUp(false); //Fn to remove any related items to the PON.
}
else { alert('Unable to get results.'); }
}
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Yes, the error you are getting is caused by async and await, as these are not supported in IE.
In any case that should allow us to pinpoint the root of the problem.
While I can't say for sure what exactly causes duplication of values from the list when looping, it's most likely due to some custom code elements. If you can, I would like to ask you to comment out all your code - JS and CSS, and try to test looping without it.In any case that should allow us to pinpoint the root of the problem.
Cheers
-
- Posts: 18
- Joined: Wed May 17, 2017
Sadly it seems quite correct that await/async functions dont work in IE or Edge, will have to rewrite code for that a bit. However on to the issue at hand, as you asked I have commented out all of the code except what you see below:
Then testing in Edge (the form now works of course) but strangely still seeing the same loop and counting issue...unless it's a problem with the sharepoint list itself ^
-
- Posts: 18
- Joined: Wed May 17, 2017
Decided to do some more testing however, this time on the edit form, which has the relatedItems list already with items in it. When running the loop without making any changes it's fine:
However, if I an add an item it will count the new item twice but not the existing items:
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Joss, if at all possible, can you test this on a different site, without the workflow and other elements already created? If it's not the code, it must be something else and I have no idea what it might be. This truly is a bizarre case, for we cannot find any reason why it would appear this way. Maybe on a fresh site with very simplistic lists, you might escape it, if only for testing purpose. If not, we'll have to look even further.
On our part, we didn't manage to get anything similar in all our tests. We'll keep looking, but we also want to get as much feedback from you as possible to determine the reason of this strange behavior.
On our part, we didn't manage to get anything similar in all our tests. We'll keep looking, but we also want to get as much feedback from you as possible to determine the reason of this strange behavior.
Cheers
-
- Posts: 18
- Joined: Wed May 17, 2017
I don't think we have another Sharepoint site to test it on sadly, however there is no longer a workflow on this list since I had to recreate this list from that earlier problem.
Is it worth me sending you the code/form to try on a site/list you have? Would just would need to change a couple of the REST queries in there is all.
Is it worth me sending you the code/form to try on a site/list you have? Would just would need to change a couple of the REST queries in there is all.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 6 guests