SharePoint 2013 Retriving documents without DirName and ListID - sharepoint

I like to check on how to retrieve documents that does not belong to any List or Document Library.
Currently the documents URL in search result is something like this "http://example.com/file.doc"
I suspect the documents where at this location due to data importing using PowerShell script and the script was unable to get the path that I was uploading to.
I will like to get the details of documents like this and delete them.
Thank you.

Use powershell:
$web = Get-SPWeb http://example.com
$web.Files | select Url
if you would like to retreive from all subwebs the code would be:
foreach ($inWeb in $web)
{
$inWeb.Files | select Url
}

Related

Sharepoint rest api how to get list within url

I'm new to Sharepoint.
We created a page in Sharepoint, it contains 4 list items.
https://abc.sharepoint.com/teams/OneTeam/SitePages/Newsfeed-page.aspx
I tried to use
https://abc.sharepoint.com/teams/OneTeam/_api/Web/lists/getbytitle('Site Pages')/items?filter=PromotedState eq 2&$select=BannerImageUrl,Description,Title
But I got all the list with the Site Pages ( which is expected ).
My question is how can I get these 4 items only from the above page ( Newsfeed-page.aspx )?
R.R.
It looks like you forgot the $ before the $filter query parameter.
Can you try this instead:
_api/Web/lists/getbytitle('Site Pages')/items?$filter=PromotedState eq 2&$select=BannerImageUrl,Description,Title
That should give you all published news post pages.

Domino check access in linked document

Situation:
I have two documents: doc_parent (has access fields) and doc_file(public doc).
doc_file has field "parent_unid"( with unid of doc_parent ) and field "$file" with attachment "file_name.doc"
User get attachment by link looks like: http://server/base/view/doc_file_unid/$file/file_name.docx.
I it possible to check current user access to doc_parent, when he makes this request?
You can't do it while directly accessing the $file object. You would have to have the access to the file go through an agent via a URL that looks something like this:
http://server/base/checkAccessAndRetriveFile?OpenAgent&fileunid=doc_file_unid/&filename=file_name.docx
And then you would have to write the agent and check the access fiends in doc_parent.
There is nothing built-in that you can rely on.
On the other hand, you could just have those access fields exist in both doc_parent and doc_file, and then none of this would be necessary.

Remove all site collections under one specific path

I have a web application with 100 site collections under the /sites/ path.
Also a root site collection in the root /
I need a powershell script to delete all of them except the root site collection.
I know the powershell command is remove-spsite but I dont want to type 1000 urls
Get-SPSite: Returns all site collections that match the given criteria.
Get-SPWeb: Returns all subsites that match the given criteria.
Remove-SPWeb: Completely deletes the specified Web.
By piping one command into the next you should be able to delete all web sites. The final whatif parameter shows what will happen.
Get-SPSite | Get-SPWeb | Remove-SPWeb -whatif

What field contains the "created date" in a SharePoint Search Index?

We need to list documents, list items, etc from a Sharepoint Search Server Express Index by the created date. The problem is we can't find it in the index even though we've tried to map it to everything we can think of.
In the Central Admin/Shared Services Administration you will go to the Search Administration page. I added the metadata properties of most of the date/time fields I could find that could be the Created Date that I am looking for. I have tried all the following properties and none of them return the date I am looking for.
I then “Reset all crawled content” and ran a full crawl.
We are using Search Server Express 2008 and WSS 3. We call the Microsoft.Office.Server.Search.Query.FullTextSqlQuery to return the data.
We use a query like this:
#"SELECT Title, SiteName, SiteTitle, Write, Path, Filename, ListId, ListItemId,
Created,CreatedBasic14,CreatedBasic16,CreatedBasic4,CreatedDC, CreatedOffice10, CreatedOffice11,CreatedOffice13,CreatedStartDate,CreatedStartDate1,CreatedPublishedDate,CreatedDateOpened
FROM portal..scope()
WHERE (CONTAINS (contentclass,'STS_ListItem_DocumentLibrary'))
AND ContentType <> 'Folder'
AND (SITE='" + SPContext.Current.Site.Url + "')
My question is what property do I have to set that will allow me to get the correct created date?
Map "Created" to "Basic:15(Date and Time)" to get creation date of a list item.
Answered by Maksymilian Mulawa on sharepoint.stackexchange.com

Placing Share Documents subfolder as a webpart in SharePoint

I want to place a Webpart on a page that holds a subfolder of the Document Library in SharePoint, but somehow, the only thing I get is the root folder of the document library.
Is there a Webpart that fills this need?
Here is how to do it in Sharepoint 2010 with only Javascript, no SharePoint Designer necessary.
create a document library web part on your web part page
change the view to show all items without folders and set the item limit to a sufficiently large number so that there are no batches
add Content Editor web part below document library web part
Add the following javascript and change the the first variable to meet your needs
Note: If you have more than one Document Library web part, you will need to add to this code.
<script type="text/javascript" language="javascript">
//change this to meet your needs
var patt = /FOLDER%20TO%20SEARCH/gi;
var x = document.getElementsByTagName("TD"); // find all of the TDs
var i=0;
for (i=0;i<x.length;i++)
{
if (x[i].className =="ms-vb-title") //find the TDs styled for documents
{
var y = x[i].getElementsByTagName("A"); //this gets the URL linked to the name field
//conveniently the URL is the first variable in the array. YMMV.
var title = y[0];
//search for pattern
var result = patt.test(title);
//If the pattern isn't in that row, do not display the row
if ( !result )
{
x[i].parentNode.style.display = "none"; //and hide the row
}
}
}
</script>
By default I don't think that is possible.
The list web part that would show the Shared Documents understands how to render the library, but doesn't understand how to filter to only show the contents of one subfolder.
It would be nice to create a Filter Web Part and to provide that filter to the List web part so that it filters according to the sub folder defined within the fileref field of the document library. However the filters it appears to be able to consume are Type, Modified and Modified By. So you could filter it to just the documents you touched, but not the ones in a given location.
End result: Roll your own web part.
The reason is that the folder selected by the webpart is not controlled by the webpart itself, but by a querystring parameter.
e.g.
"?RootFolder=%2fDocuments%2fMyFolder1&FolderCTID="
So folders are not "real" folders as such, despite the "lie" that is the webdav interface
e.g. \\sharepointsite\documents
There should be a way of including the desired RootFolder parameter, like a linking to the page with the querystring included (far from ideal).
I do not know of any webparts that do this.
I was able to do this by creating a new Column and specifying a keyword for the entire Shared Documents list.
Then I had to add metadata.
Add the WebPart again to the page.
Create a View that enabled the display of the files as a flat list, and filter on the new Column (i.e. where Keyword is/contains ----).
Then I get the list I want on the page with the web part.
I have a work around I've used that doesn't required Designer. Not as elegant, but achievable by any power user.
After you've added the library web part, go to the page and click down to the folder you want to be the default. See that the page link now shows something like :
www.mysite.com/sharepoint/default.aspx?RootFolder=%2Fsubfoldername&FolderCTID=...
Copy that link. Delete &FolderCTID and everything that follows. In this case what remains is :
www.mysite.com/sharepoint/default.aspx?RootFolder=%2Fsubfoldername
Use this link for navigation to the page and the library will display as you want within that page. Be aware it does not replace the default view for that page.
Another way of face this issue would be to just use the Content Search WebPart ( CSWP ) and filter the results based on :
folder path
url depth
You will need a UrlDepth value that matches your requirement. The best thing is to use a high value, like 10, and then reduce until it shows just the files you need.
Regarding folder path, remove the (quotes) ", this way the query will perform a "contains" lookup, instead of "equal to":
Result will be something like this:
path:[your site]/Docs/our_team UrlDepth:7
If the folder name contains spaces, you may need to wraps it with quotes. something like:
path:[your site]/Docs/"our team"
One alternative I've used is to drop a Page Viewer Web Part on the page and choose "Folder" as the type of thing to view. Then specify the webdav UNC to the folder such as "\some_sharepoint-site\some_site\shared documents\some_folder\"
Place the document library list view web part on any page.
Edit the web part.
From filter select column "Content Type" and value "Folder"
Save and you are done.
By doing that it will show you root folder files only.

Resources