SharePoint Author/Created By
SharePoint Author/Created By
bigjohn1982
Posts: 3Questions: 1Answers: 0
Hi, I've been trying to integrate a SharePoint list with Datatables which is working fine. Data is retrieved and displayed as expected, but whenever I try to use the Created By/Author column in SharePoint I get a "Requested unknown parameter" error.
I know in SharePoint the display name is "Created By" and the internal name is "Author". But neither seem to work.
Anyone any ideas?
Thanks...
John
This discussion has been closed.
Answers
We;d need to see the code you are using and the JSON data or a link to the page.
Allan
Apologies, I just realised that the REST service only returns the AuthorID. I should be able to figure it out from here.
Sorry for wasting your time!
Hi again Allan,
I've managed to get the AuthorId from the SharePoint REST query, and I've managed to get the the User's Name using SPServices.
I would like to replace the mData: AuthorId with the value I get from getUserInfo. Any ideas how I might be able to do that.
Thanks in advance.
Here is my code
You could use
columns.data
as a function rather than a string. However, ifgetUserInfo
makes an ajax call that isn't going to work, even even if it did it would kill performance.Allan
To do it wholly with REST and not fall back to SPServices you need to have 'Author/Name' in your
$select=
clause and 'Author' in your$expand=
clause.Here is another method to get the current users ID without and AJAX call SPServices or not:
Your line 30:
url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/getByTitle('MyList')/items?$select=Title,AuthorId, Description&$filter=Author/Id eq '" + thisUserAccount + "'",
to:
url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/getByTitle('MyList')/items?$select=Title,AuthorId,Author/Name,Description&$expand=Author&$filter=Author/Id eq '" + thisUserAccount + "'",
Your line 46:
{ "mData": "AuthorId" },
with:
{ "mData": "author.id" },
This should get you close. I have used it in much of my code base and for retrieving file names and making links.
If you
$select
for 'File/ServerRelativeUrl,File/Name', then$expand
for 'File'; you can build links to your documetns like this: