Get list properties in columns calculated value
Hi @all,
is it possible to get the list id of a specified list in Things in background -> calculated values of a link column. The requirement is to calculate a link column with link to version history of an element.
I tried this Function Code but it did not work:
==================================
var list;
var listId;
function getListId() {
var context = new SP.ClientContext.get_current();
var web = context.get_web();
list = web.get_lists().getByTitle('Vertraege');
context.load(list, 'Id');
context.executeQueryAsync(Function.createDelegate(this, success), Function.createDelegate(this, error));
}
function success() {
listId = list.get_id();
console.log(listId);
}
function error(sender, args) {
alert('Request failed. ' + args.get_message() +
'\n' + args.get_stackTrace());
}
// INIT
getListId;
var url = [[@Web.Url]]+'/_layouts/15/Versions.aspx?list='+listId+'&ID='+[[ID]]+'&IsDlg=1, Versions';
return url;
==================================
It returns undefined for listid. :-(
Successful evaluation with result: ""/sites/dev-vm/_layouts/15/Versions.aspx?list=undefined&ID=79&IsDlg=1, Versions""
How could I implement to get the list id?
Thanks in advance.
Jens
-
Hi Jens Hetze,
this will not work like that in the background, as there is no clientcontext object.
But for now you could set this e.g. in the NewForm on the savebutton using an update list item action after the save action:

In the client-side Expression Builder there is a form context with the ListId available.
Just use an Assignment Expression like:
[[@Web.Url]]+'/_layouts/15/Versions.aspx?list='+[[@Form.ListId]]+'&ID='+[[ID]]+'&IsDlg=1, Versions'
Cheers
Matthias
0
Please sign in to leave a comment.
Comments
1 comment