Forms expression to query SharePoint listAnswered
In one of my expressions used in a form I need to query the ID field for the most recent item in the SharePoint list. I can see that there is a QueryList function under Site Context Objects when building my expression but I'm not sure how I can use this to query the ID of the newest item currently in my list.
Is this possible, and if so, how would I do this?
Many thanks for your help in advance.
Hi Gareth Jayne,
you can use the following function to query the ID of the newest item in a list:
[[@Web.GetFirstValueForQuery('Contacts', '<Where></Where><OrderBy><FieldRef Name=Created Ascending=False /></OrderBy>', 'ID')]]
Just use an empty <Where></Where> query and order by the field 'Created' descending.
or use this to get the latest item ID created by you:
[[@Web.GetFirstValueForQuery('Contacts', '<Where><Eq><FieldRef Name=Author LookupId=True /><Value Type=User ><UserID/></Value></Eq></Where><OrderBy><FieldRef Name=Created Ascending=False /></OrderBy>', 'ID')]]
This function is available in the expression builder under the web context object.
Please sign in to leave a comment.