Programmatically set default column values based on folder in SharePoint Online - default-value

I'm working on enhancing metadata in our SharePoint online (O365) environment. Since a portion of my user base is used to foldering (explorer style), I've started using default column values to automatically set values on any files added to that specific folder (we have content organized categorically by folder currently). An example is our HR documents library - we have separate folders for recruiting, payroll, personnel files, etc. that automatically categorize files added to that folder with the same categories (recruiting, payroll, personnel, etc.). This supports both "search" and "click" users and makes adoption WAY easier while getting important metadata.
I want to implement this in a larger, more dynamic fashion, so manually setting default column values on each folder is not going to be scalable.
How can I reference the top level folder within the library (or even the current folder) for each newly added file and populate the "category" field for that new file with that folder name? I can do some very basic C# or Java code copy/paste, but bonus points for non-coding solutions =)

This problem can be solved through no coding.You can use the workflow to implement this by SharePoint Designer.
Create different view for different function team, and then use the view filter to show the document.
If you upload a file, use the workflow to set the metadata of the file. There are some known limitations: if you upload multiple files at the same time, the metadata for the file maybe does not work well; or if you upload a folder, the meta will not work for it and the file in the folder may not be set to right metadata.

I was actually able to use MS Flow to accomplish this in a pretty simple and straightforward fashion without managing custom views per team. The concept at a high level was:
(Trigger) When a new document is created in a folder in the library
Get the link of the parent folder of the newly added document
Create a variable (or just code it out in the Flow step) to parse out the name of the parent folder from the parent folder link (should be all text to the right of the last "/")
Set the category field as the variable
I'm sure that you could do the same right in a SharePoint designer workflow, but I prefer flow due to the visual aspect of it and being far easier to troubleshoot.

Related

Cant copy files from one document library to another- sensenet

I am using sensenet and react based client for front end. while copying a file from one document library to another I am getting the following error:
"Cannot copy a list item into an another list".
Can anybody tell me how i can solve this?
This behavior is currently by design. The reason is that content lists (doc lib, task list, etc.) may contain local list fields. If you had a document in a list with a custom metadata field filled with a value, you would loose that value if you copied the document to another list.
Workaround 1
If you do not need the list/library functionality (custom metadata fields, etc.) than store documents in a simple folder instead of a list. This will let you copy those documents wherever you want - even into a list. In this case you have to take care of setting the allowed child types (most likely File) somewhere on the parent chain (e.g. on the workspace), because you cannot set this value on simple folders.
Workaround 2
Copy files using a temp folder. It is allowed to copy a file from a list to a temp folder, and also copy a file from a folder into a list. I know, this is not very convenient and we are considering changing this behavior to make it more permissive, but this is how currently works.

Visual Studio Unit Test Data Path and Source Control

I have a unit test project for my VB.NET solution that takes a very large data set (multiple Gigabytes). The data set is static, outside of source control (developers unzip a big .zip file somewhere on their machine)
I'm trying to figure out how to reference this data set inside my project and I'm having trouble because of the following constraints:
The data set may be in a different location on each developer's machine e:\dev\MySolution\TestProject\ vs. c:\MySolution\TestProject\data. We can require it to be in the project folder but I can't require that the project folder be in the same place. This means I can't store the path in source control or I need some way to override it.
Because of its size I don't want to have to copy or deploy the test data at runtime because this will slow things down a lot and I don't want to have two copies of it.
My hack-y solution is to use a project property called DataPath and reference this inside each test. Then users would just change the property and I'd instruct them not to commit this change.... feels like an anti-pattern though.
My initial thoughts were to somehow store the path in the project.suo file which is outside of source control but I can't figure out how to make that work.
Anyone have experience with this?

VB.NET Create downloadable resource

I've become stuck at this hurdle. I'm trying to create a database that clients fill in, however the client can set different database paths to view different information in the program. I want to create template databases so should they wish to create a new database it will work with the SQL queries the program uses.
I'm trying to save the templates in to the program so that when a button is clicked, the template file is "downloaded" (copied) to the clients desktop.
Is this even possible?
Thanks
You can open the Resources page of the project properties and add any existing file, including a SQL Server MDF data file. At run time, you can get the data of the file from the appropriate property of My.Resources. The type of the data depends on the type of the file. I'd expect that an MDF file would come back as a Byte array, which you can then write to a file or whatever.
That said, you don't want to make your EXE too big by embedding several sizeable data files in it. You might be better off just using loose files in a subfolder or, if you're determined to use resources, create a satellite assembly, i.e. a DLL that contains just resources.

Need VB.NET Resource Files clarification

In a VB project I can add a resource via the project properties resources tab, or I can right-click the project in the solution explorer, click add, then click add existing item.
What are the differences?
If I want to add a DLL file and include it as an embedded resource, do I have to add the file via both methods? Only one?
Thanks.
What you are describing is linked and embedded resources.
Check out this page which describes the differences:
Linked vs. Embedded Resources
From the MSDN link above:
Embedded Resources
Embedded resources are the best choice if you need to share application resource (.resx) files between multiple projects.
For example, if you have a common resource file that contains your company's logos, trademark information, and such, using embedded resources means you only have to copy the .resx file and not the associated resource data files.
You cannot edit embedded resources directly. If you try to edit an embedded resource, you will receive a message prompting you to convert the item to a linked resource in order to edit it; conversion is recommended but optional. You must export them, make your modifications in an external program, and then import them back into your project.
Linked Resources
Linked resources (the default) are the best choice for ease of use.
Resources can be edited directly inside the project, and you can easily add or remove resources as needed.
Edit
You would only need to add your DLL using one method. Which one you select depends on which method best fits your needs (as per the descriptions above)

Is _mmServerScripts necessary?

When developing sites using Dreamweaver, it creates a _mmServerScripts directory on the root of your site. We've been reading that this folder contains SQL statements that are vulnerable to attack. We would like to avoid this all together, if possible. Is this folder even necessary? Can you do anything to Dreamweaver to tell it to never create these folders?
Thanks in advance.
When you're creating dynamic pages with Dreamweaver, it creates files in the _mmServerScripts folder. Those files are used to obtain information about your database, such as table names, table columns, and column types. This information is used within the built-in server behaviors (and possibly third-party extensions) in order to generate the appropriate code to insert into your page. One such server behavior would be the Recordset server behavior. This interface allows you to select a data source, table name, and column names to include in the recordset.
If you do not use any of the dynamic data functions within Dreamweaver, it probably does not create the _mmServerScripts folder, but if you use that functionality, it will create that folder. If you want to remove the files in this folder, which is hidden within the Dreamweaver Files panel by default (show hidden files: Files panel option menu on the upper right of the panel, View -> Show Hidden Files) by selecting:
Site -> Advanced -> Remove Connection Scripts
I do not have a very extensive knowledge of the contents of the files, so I can't comment knowledgeably about what, if any, vulnerabilities exist within the files within the folder, but it would be good to include links to such discussions you've been reading about.