1

Is there a way to programatically set the default value of a column in SP2013? Here is my use case scenario:

I have a project site collection. A form is used at the top level site to create a site using a specific site template via a workflow. The site is created with a custom document library with some fields [Project, Project Manager, Et]. These values will be the same for every file in the document library. Is there a way to set default values via a workflow so that each time a file is uploaded to this document library, the information is already populated?

I am using SP2013 OnPrem.

  • You can create a workflow when item is added and then fill default value. Or by developing an event receiver when an itemcreated. – Ahmed Bouchaala Jan 25 at 9:37
  • Hi Ahmed, thank you for your response! Unf I don't have access to farm for the farm solution & we'll be upgrading to SPO soon. I guess I didn't explain it well. I'm worried that a workflow for every doc that is uploaded is taxing. The form creates a new project site based on the entries in the form. I wanted to know if there was a way to SET the default values automatically instead of having to go to every project site's library settings & setting the column default values there. – user2004758 Jan 25 at 21:44
1

If you are creating custom fields, you can set Default Value, just edit these fields in Library Settings:

enter image description here

$w = Get-SPWeb http://localhost  
$l = $w.GetListFromUrl("/Lists/SampleList2/AllItems.aspx")  
$f = $l.Fields["First Name"]  
$f.DefaultValue = "my default name" 
$f.Update()
  • Hi Zdenek, thanks for your reply. Yes I know about changing in Library Settings. I don't want to manually go in & set the values each time a site is created via the workflow. I'm wondering if there is way to set the default values via a workflow when the document library is created. I can't run any PowerShell scripts as I don't have access to the server to do so. – user2004758 Jan 28 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.