Jump to content
  • How to Get or Set Custom Property for a Library Item in Spotfire® Using IronPython Scripting


    This article provides a sample IronPython script on how to get/set a custom property for an Library Item like an analysis file.folder etc.,

    Introduction

    This article provides a sample IronPython script on how to get/set a custom property for an Library Item like an analysis file.folder etc.,

    Code Sample

    # Copyright © 2019. TIBCO Software Inc. Licensed under TIBCO BSD-style license.
    
    from Spotfire.Dxp.Framework.Library import *
    from System import Array
    
    fileName = "/batchprint"
    # Set up the LibraryManager and ensure that we can 
    # access the folder path specified
    libraryManager = Application.GetService[LibraryManager]()
    success, item = libraryManager.TryGetItem(fileName, LibraryItemType.Analysis,LibraryItemRetrievalOption.IncludeProperties)
    if success:
        found,prop= item.Properties.TryGetProperty("myCustomProperty")
        if(found):
            for value in prop.GetEnumerator():
                print value
        else:
            settings=LibraryItemMetadataSettings ()
            values = Array.CreateInstance(str,2)
            values[0]="myvalue3"
            values[1]="This is a new Value"
            settings.SetProperty("myCustomProperty", values)
            libraryManager.SetLibraryItemMetadata(item,settings)
            print "Created a new Property"
     

    References

    License:  TIBCO BSD-Style License

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...