Display Username in CSL
- Mostafa Mohamed
- Posts: 6
- Joined: Tue Jul 26, 2016
i need to display the user display name in csl field via an "Assigned To" column, but curruntly displaying "undifined", here my code and screen shot:
Request items:
function (term, page) {
if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Title,ActivationDate&$orderby=Created desc&$top=10";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Title,ActivationDate&$orderby={LookupField}&$filter=startswith({LookupField}, '" + encodeURIComponent(term) + "')&$top=10";
}
Item format:
function(item) {
return '<div style="height: 50px; clear: both;"><div style="width: 45px; float: left;"></div><span>' + item["Title"] + "<br>" + item["{LookupField}"] + "<br>" + item["ActivationDate"] + '</span></div>';
}
Request items:
function (term, page) {
if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Title,ActivationDate&$orderby=Created desc&$top=10";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Title,ActivationDate&$orderby={LookupField}&$filter=startswith({LookupField}, '" + encodeURIComponent(term) + "')&$top=10";
}
Item format:
function(item) {
return '<div style="height: 50px; clear: both;"><div style="width: 45px; float: left;"></div><span>' + item["Title"] + "<br>" + item["{LookupField}"] + "<br>" + item["ActivationDate"] + '</span></div>';
}
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hi,
Please, try these snippets:
Item format:
Please, try these snippets:
Code: Select all
function (term, page) {
if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id," +
"{LookupField},User/Title&$expand=User&$orderby=Created desc&$top=10";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id," +
"{LookupField},User/Title&$expand=User&$orderby={LookupField}&" +
"$filter=startswith({LookupField}, '" + encodeURIComponent(term) + "')&$top=10";
}
Code: Select all
function(item) {
return '<span class="csl-option">' + item["{LookupField}"] + " " + item["User"].Title + '</span>'
}
-
- Information
-
Who is online
Users browsing this forum: No registered users and 4 guests