Hi,

I've had a request from one of my users to create a script on our hosted wiki that will create all the needed wiki content for one of their lists. 

I've tried using the $xwiki.createDocument in the underneath code (most likely more saves than necessary). 
What seems to be happening is this:

Origionally had it saving after each change, no difference.

#set($seedForUnique=$xwiki.formatDate($xwiki.currentDate, "HHmmssddMMyyyy"))
#set($userUnique=$context.user.replace("XWiki.", ""))
#set($generatedUnique="${userUnique}${seedForUnique}")
#set($baseAVLClass='XWiki.AVLEntryClass')
#set($baseSupplierClass='XWiki.VendorClass')
#set($newSupplierPartClass='XWiki.AVLVendorClass')

#set($newDocument=$xwiki.createDocument())
$newDocument.rename($generatedUnique)
$newDocument.setContent('#includeForm("AVL.VendorClassSheet")')
$newDocument.createNewObject('${baseSupplierClass}')
$newDocument.save()
#set($docObj=$newDocument.getObject('${baseSupplierClass}', 0))
$docObj.set('name', 'Samsung')
$docObj.set('email', '')
$newDocument.save()

I would guess I'm not doing a crucial step (or doing that step wrong)?
Better suggestions welcome too :)