Hi,
i would like to do the following:
I have a wizard with 6 Steps.
In the first step the user enters a Project name.
In the 4th Step i have a 2 linked Documents Library where i would like to give the user the possibility to upload documents -> but i would already need sub-folders with the project name defined in step 1.
Is there a way to make this happen?
If not, is there a way that they upload the documents and when clicking save that i move the documents from the root folder to the created sub-folder?
thanks a lot in advance for a hint how to make it happen
Andreas
Hello @Margo,
thank you so much for your reply, i will check all the info you provided and come back to you in case of anything unclear - but seems straight forward from what i read.
Just one last question:
i guess it should work, just to be sure. When i am able to detect a wizard step change, i would also be able to set the content of the "Project name" from the first step to a (for the user) "hidden" field which would be the project folder name -> just want to prevent that when the project name gets changed later on that we run into troubles with folder names -> so i would make a fixed name then which can't be edited.
Makes that sense or is there already in the process of creating a new list item an ID available which i could use? i didn't found anything...
Hi @Margo
i am struggling with getting the code to work - i would like to run it only when foldername is still empty and a wizard change is detected... but don't know how to connect the dots..
fd.spRendered(function () {
fd.container('TSIWorkbookWizard').widget.$on('on-change', function() {
//copy projectname to foldername
fd.field('FolderName').value = fd.field('Projectname').value
var agentName = fd.field('Foldername').value;
//create folder in ProductCataloguesAttachments document library
var folder1 = pnp.sp.web.lists.getByTitle("ProductCataloguesAttachments").rootFolder.folders.add(agentName);
//create folder in Outgoing document library
var folder2 = pnp.sp.web.lists.getByTitle("SampleTicketsAttachments").rootFolder.folders.add(agentName);
} );
});
thanks for your answer,
i am now able to create the folders at the right place.
Where i now have an issue is that i would also need to change after creation the root folder.
So, i am able to recognize when a wizard step is changed and i am creating the folder before the step is opened where i would need to set the root folder of 2 diffferent "SPDataTable".
This is right now, what i use as code to create the Folder.
What do i need to do that i can also set the root folder? i tried this one:
//create folder in ProductCataloguesAttachments document library
var folder1 = pnp.sp.web.lists.getByTitle("ProductCataloguesAttachments").rootFolder.folders.add(TempFoldername);
//create folder in Outgoing document library
var folder2 = pnp.sp.web.lists.getByTitle("SampleTicketsAttachments").rootFolder.folders.add(TempFoldername);
return Promise.all([folder1, folder2]);
//var agentName = fd.field('Order Number').value + dmy;
fd.field('FolderName').value = TempFoldername;
// After Folders have been created also change the root folder that the documents get uploaded into the correct created folder
var dt = fd.control('SPDataTable4');
dt.ready(function() {
setRootFolder();
});
//set root folder when Category field changes
fd.field('FolderName').$on('change', function() {
setRootFolder();
});
function setRootFolder(){
alert('RootFolderSet ');
var category = fd.field('FolderName').value;
if(category){
dt.baseRootFolder = category;
dt.rootFolder = category;
}
}
return Promise.all([folder1, folder2]); — can be used in asynchronous functions only.
Try out change the code like this:
var dt = fd.control('SPDataTable1');
pnp.sp.web.lists.getByTitle("ProductCataloguesAttachments").rootFolder.folders.add(TempFoldername).then(function(){
fd.field('FolderName').value = TempFoldername;
//set root folder when the form loads
dt.ready(function(dt) {
setRootFolder(dt);
})
})