1

This is the New Form for a Document Set. The text in the red box is the text I'd to be autopopulated upon every New Form Page Load (i.e. when a new Document Set is created). I have no idea how to do this, because I can't edit the New Form for a Document Set Library in Sharepoint Designer.

  • As soon as the Doc Set is created, it goes through a Workflow where it will be renamed automatically, ensuring every document set will have a unique name.

Edit: here's the javascript I'm planning on adding.

<input type="text" class="form-control" name="FileLeafRef" />
<script>
var jsonData = {
  a: ADMIN Do Not Edit
};
var jsonDataKeys = Object.keys(jsonData);
var inputElements = document.getElementsByTagName('input');
for(var i=0; i<jsonDataKeys.length; i++){
document.getElementsByName(jsonDataKeys[i])[0].value = jsonData[jsonDataKeys[i]];
}
</script>
  • Can you edit this page and add script editor webpart? – Amal Hashim May 25 '16 at 15:32
  • If there's a way to do that, I don't know how. I'm not given the option to modify the New Form. I'm also uncertain about the script to put in the script editor. Please see my revised post – TheJDScott May 25 '16 at 19:32
2

The NewDocSet.aspx Page

If you look at the URL of this page you'll see it looks something like

http://site/_layouts/15/NewDocSet.aspx

You can see that NewDocSet.aspx lives in the LAYOUTS folder of SharePoint's "hive". This is a term that just refers to SharePoint's installation location on the server.

The hive on the server will be at

C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15

And the LAYOUTS folder will be in the hive at

TEMPLATE\LAYOUTS

As you've already discovered, you can't edit NewDocSet.aspx from the GUI. This is because this page sits in SharePoint's hive.

How to Customise NewDocSet.aspx

To make changes to this page, this file in the hive on the server is the one you need to edit. However, it is recommended you do not change the default file. Instead, make a copy of it first in the same location, call it NewDocSet_custom.aspx, and change this file.

Once you've made your changes you need to tell SharePoint to point to this new file. To do this, open your site in SharePoint Designer. On the left click Lists and Libraries and open the document library that contains your Document Set content type. In the Content Types panel click your Document Set content type. In the Forms panel you'll see the location of the New Form for this content type. It will probably be currently set to _layouts/15/NewDocSet.aspx. Change this to your new file, i.e. _layouts/15/NewDocSet_custom.aspx. Click Save in SharePoint Designer.

Now when you attempt to create a new document set, it will navigate to your new page.

How to Auto Populate Name Field

You can achieve this with a bit of JavaScript.

Edit NewDocSet_custom.aspx and find this line:

<asp:Content ContentPlaceHolderID="PlaceHolderMain" runat="server">

Directly under this line add this code:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
    $("input[id^='FileLeafRef']").val("ADMIN Do Not Edit");
</script>

Save it and proceed to create a new document set. You should now see the Name field auto populated.

Note that this JavaScript pulls jQuery from Google's servers. I'd recommend you take a copy of jquery.min.js and put it in your Site Assets folder on your site. Note also that you are adding JavaScript directly into NewDocSet_custom.aspx. My recommendation would be to add a JavaScript file to your Site Assets library on your site and put this one line into that file and only reference the file from NewDocSet_custom.aspx. This way if you need to make a change to your JavaScript you're only ever changing the JavaScript file in your Site Assets library, rather than having to change NewDocSet_custom.aspx on the server. In this case this is what you would add in NewDocSet_custom.aspx:

<script type="text/javascript" src="http:/yoursitelocation/SiteAssets/jquery.min.js"></script>
<script type="text/javascript" src="http:/yoursitelocation/SiteAssets/mycustomscript.js"></script>
  • Unbelievably helpful, thoughtful, and thorough. Thank you. – TheJDScott May 26 '16 at 16:30
  • Weird issue -- the form stopped autopopulating. I'd did everything as you'd suggested, and it no longer works for whatever reason. The code was placed here as follows in the newdocset_custom.aspx I'm no sure that i know how to use the minimarkdown language, here it is <asp:Content ContentPlaceHolderID="PlaceHolderMain" runat="server"> <script type="text/javascript" src="ajax.googleapis.com/ajax/libs/jquery/1.12.4/…> <script> $("input[id^='FileLeafRef']").val("ADMIN Do Not Edit"); </script> <SharePoint:SPPageStatusSetter id="PageStatus" runat="server"/> – TheJDScott Jun 28 '16 at 16:15
  • Please ask another question. If it was working and now isn't, something must have changed. – Submits Jun 28 '16 at 17:25

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.