How to get the latest item created by me using expression functions

Document created by Matthias_Walter Employee on Mar 13, 2018
Version 1Show Document
  • View in full screen mode

Sometimes we need to get a value of an item we've just added to a list e.g. the ID.

There is an easy way to achieve this using the expression language and a function called GetFirstValueForQuery which is there to query a list using the standard caml query language.

 

In the skybow expression builder expand the context node and dbl-click on the function GetFirstValueForQuery under the web or site node.

The following will be added to the expression text box on the left:

[[@Web.GetFirstValueForQuery('ListName or relative Url', 'Caml query', 'FieldName')]]

 

Now just replace the parameters for the list to query in, the actual caml query and the field you want to retrieve.

 

Final expression to get the ID of the latest item created by me looks like this:

[[@Web.GetFirstValueForQuery('Project', '<Where><Eq><FieldRef Name=Author LookupId=True  /><Value Type=User ><UserID/></Value></Eq></Where><OrderBy><FieldRef Name=Created Ascending=False /></OrderBy>', 'ID')]]

This can be used exactly like this for every list or library. Simply change the first parameter for the list using the list name , the list ID or the list url as described here: How to use query functions

Attachments

    Outcomes