title: Spotfire SaveAs using ironPython
body: <p>I am trying to SaveAs a document as a library item on 'onPropertyChange' event using ironpython script.
  the script`s code attached to the property :</p>
  
  <pre><code># Import namespaces
  from Spotfire.Dxp.Application import DocumentSaveSettings
  from Spotfire.Dxp.Framework.Library import *
  
  # Set the folder path and file name
  folderName = "/Spotfire Test Folder/Reports"
  fileName = "Test File"
  
  # Set up the LibraryMangager and ensure that we can 
  # access the folder path specified
  libraryManager = Document.GetService(LibraryManager)
  success, libraryFolder = libraryManager.TryGetItem(folderName, LibraryItemType.Folder)
  
  # Embed the data
  Document.Data.SaveSettings.EmbedAllSourceData = 1
  
  # Save the document back to the Library
  Application.SaveAs(libraryFolder, fileName, LibraryItemMetadataSettings(), DocumentSaveSettings())
  </code></pre>
  
  <p>Unfortunately, I get the following error :</p>
  
  <p><strong>Invalid operation 'BeginAggregatedTransaction' to the command history when in state 'Executing'</strong></p>
  
  <ul>
  <li>Is there a problem with the script ? in case not , is there a way to save as a library item using a script or an api function (via javascript or ironpython)?</li>
  </ul>