This project has moved and is read-only. For the latest updates, please go here.

Automatic set up of unique doc library name..

Oct 4, 2011 at 5:24 AM

Hi Marc,

I am trying to create a folder structure in a document library when a new item is created in a list. However, I want the folder name to be a static value concatenated with the current list item id from the list. I have been able to get the values to append and save in a variable -newId. However the updatelistitem code does not get called. 

Can you please help me with where the error in the code is?

<script language="javascript" type="text/javascript">
function PreSaveAction() {
var lastId = $().SPServices.SPGetLastItemId({
listName: "BB Meetings"
var newId= "Business Building - " + (parseInt(lastId,10)+1);
operation: "UpdateListItems",
async: false,
listName: "Meetings Content",
updates: "<Batch>" +
"<Method ID='1' Cmd='New'>" +
"<Field Name='ID'>New</Field>" +
"<Field Name='ContentType'>Folder with Category</Field>" +
"<Field Name='BaseName'> "+ newId +" </Field>" +
"<Field Name='Meeting_x0020_Title'>" + newId + "</Field>" + "<Field Name='Folder_x0020_Category'>BASE</Field>" + "</Method>" +

Thank you for your help.


Oct 4, 2011 at 3:29 PM


It looks like some of your code is missing above. From what I can see, things ought to be heading in the right direction. However, make sure you havew terminating semicolons on every line; I see one missing above.

I'd suggest adding an alert in the completefunc for the UpdateListItems:


This will show you what is being returned in the XML, which may indicate an error.