Delete entries in a folder using PNP.js - sharepoint

I have a list with number of folders and inside each folder i have entries. How to delete all entries inside a folder using pnpjs?
sp.web.getFolderByServerRelativeUrl('/site/<siteName>/<FolderName>').files.recycle().then(i => { // successfully deleted })
I can't be able to use recycle after files.
If you can help in query that would be a great help!. Thanks

Related

How to delete multiple folders from SharePoint using PowerAutomate

I was able to delete multiple files, but I would like to know how to use PowerAutomate to delete multiple folders in a SharePoint library at once, as the library may have folders as well as files.
You could use use the "Get files" SharePoint action, add the condition if ISFolder = true, delete the item. Note: in delete item action, you need to enter custom value. Like this:

The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator while renaming site column

I am getting
"The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator"
while renaming site column in SharePoint online using CSOM. I have faced this issue in the past while fetching items from the large list but this is a different scenario, here I am just trying to rename the site column.
This issue is caused by the Item Count exceed the list view threshold limitation. And No matter retrieve item or rename site column with CSOM, it will throw such exception.
For SharePoint Online, to come across this limitation, here are some way:
Use indexed column.
Reduce the list item and create multiple views which make sure the item count is less than list view threshold.
More information please refer:
Office 365: How SharePoint Online handles List View Threshold
I faced the same issue accessing the folders from Sharepoint online. One of my subfolder under Sites rootfolder had 6000+ subfolders, resulting to threshold limit error. So instead, I user alternative way to access only specific folder that I need using GetFolderByServerRelativeUrl function. Steps were...
Get Online Context
Get List of items. It will also provide the root folder.
Using GetFolderByServerRelativeUrl, get only specific folder within this root folder. Below code may help further.
private Folder GetSubFolder(Web web, Folder rootFolder, string subFolderName)
{
Folder subFolder = null;
try
{
//If folder exists, get the folder form Sharepoint Cloud
subFolder = web.GetFolderByServerRelativeUrl(rootFolder.ServerRelativeUrl + "/" +subFolderName);
web.Context.Load(subFolder);
web.Context.ExecuteQuery();
}
catch (ServerException ex)
{
subFolder = null;
}
return subFolder;
}
}

Default folders on SharePoint Document Set

I'm trying to achieve a project documentation solution on SharePoint 2013 using a custom Document Set Content Type. Each new project Document Set would hold four types of documents.
My initial thought was to use folders for each type to allow easy drag and drop behavior for adding documents. The problem is, by default, folders can be created only by adding default documents to a Document Set Content Type. I wish to create the folders upon the creation of new instance of this Document Set but not add any documents inside these folders.
This is what I have tried so far:
Using workflow to delete default documents inside folders that were created in the new Document Set.
Custom folder Content Types.
The reason for use of folders is to avoid metadata tagging when uploading documents.
I'm quite restricted with the tools that I can use so the most basic level solutions would be appreciated.
To be more clear, I would hope to have a Document Set Content Type which holds four folders. Document Set would act as a holder for all documentation relevant for a single project and folders inside would group the documentation into groups. Each new project will generate documents in its lifespan and these documents should be grouped into categories, say marketing, finance, production and HR. So when I have a new project, I can create a new instance of custom Document Set with pre created, named, empty folders inside.
There's two ways you can achieve this I think. First would be to set-up your document set to have an empty document deployed to all of the folders you'd like to create. Simply add "Default Content" to your document set and there specify the correct folders. Unfortunately there's no way to create empty folders, so you'll need to put a dummy document in each folder which the user can then delete or override.
Second would require some coding. By attaching a remote event receiver to the library, you could trigger some custom code which would create the folder structure inside of the document set once created. This would allow you to create the folder structure without the need for dummy documents; so it's a bit more work which requires a developer, but the end result is also better.
The second solution you might also be able to pull off in a workflow (or Microsoft Flow) which then uses the API's to create the folders, but that's most likely less clean and more hassle to get working.
Create a custom content type called "Folder Creator". Use that content type to create the subfolders. Then have the "Folder Creator" content type auto delete using SharePoint Information Management Policies. Be sure to set your "Expiration Policy" job to run at least once a day.

Viewing the content of a folder within a SharePoint Document Library

I have document library called 'Documents'. In there I have this folder structure 'Public' > 'Documents' > 'Legal'. To display the content i.e. Files and folders I can use a web-part.
But My problem is I only want to display the content of this 'Legal' folders document only not the whole document library documents.
How am I suppose to solve this matter?
Chiranthaka
I just add a field and stop it is been viewed. I put a value in that field and filter the view according to that value.

Can't create Sharepoint List from imported list template

I have a list with some lookup fields. On their list templates, I followed below steps:
Rename the original .STP to .CAB
Extract its manifest.xml to a local folder (lets call it {workingfolder})
Search for the ProductVersion element. This should have a value of 3
Change its value to 4
Repackage the manifest.xml into a .CAB. I've done this by using makecab.exe in the C:\Windows\System32 folder
Syntax: makecab.exe {workingfolder}\manifest.xml {workingfolder}{template-name}.cab
Change the generated cabinet's extension from .CAB back to .STP and upload it into the _catalogs/lt
I uploaded List Template using elements.xml. But I can't even access List Template using code (given below).
SPListTemplate listTemplate=null;
foreach (SPListTemplate template in SPContext.Current.Web.ListTemplates)
{
if (template.Name.Equals(templateName))
{
listTemplate = template;
}
}
return listTemplate;
I uploaded the same List Template manually with another name and debugged the code. It returns only the List Template which uploaded manually. I know this is a duplicated question, but no solution is working for me.

Resources