This VBScript example shows how to checkout an item from the MOVEit Automation config, modify it, and submit the changes. This particular example uses CheckoutItem to checkout a global parameter called NumberSeq, which keeps track of a numberic sequence of numbers. If the Checkout is successful, the script will increment the value, editing the XML to reflect this change, and then re-submit the XML using ModifyItem to update the MOVEit Automation config with the changes that were made.
Option Explicit Dim oAPI Function IncrementCount() Dim ItemType, ItemID, ItemXML, Count Dim oXML, oNode Dim bOK, ErrDesc bOK = False ItemType = "GlobalParameters" ItemID = "" ' check out the GlobalParameters section ItemXML = oAPI.CheckoutItem(ItemType, ItemID) If ItemXML = "" And oAPI.GetErrorCode() = 4010 Then WScript.Echo "The global parameters section is currently checked out to someone else. Will retry in 15 seconds..." & vbcrlf WScript.Sleep 15000 ItemXML = oAPI.CheckoutItem(ItemType, ItemID) End If If Not ItemXML = "" Then ' load the XML obtained from CheckoutItem into an MSXML object for parsing Set oXML = CreateObject("Msxml2.DOMDocument.4.0") oXML.loadXML(ItemXML) ' look for a global parameter named "NumberSeq" Set oNode = oXML.selectSingleNode("//GlobalParameters/NumberSeq") If Not oNode Is Nothing Then ' get the current count of the number sequence and then increment the value Count = oNode.text Count = Count + 1 oNode.text = Count ItemXML = oXML.xml ' re-submit the modified GlobalParameter section bOK = oAPI.ModifyItem(ItemType, ItemID, ItemXML) If Not bOK Then ErrDesc = "Error modifying global parameters: " & oAPI.GetErrorCode() & ": " & oAPI.GetErrorDescription() End If Else ErrDesc = "Couldn't find global parameter ""NumberSeq""." End If Set oXML = Nothing Set oNode = Nothing Else ErrDesc = "Error checking out global parameters: " & oAPI.GetErrorCode() & ": " & oAPI.GetErrorDescription() End If If Not bOK Then WScript.Echo "Error in IncrementCount: " & ErrDesc End If IncrementCount = bOK End Function Sub Main() Set oAPI = CreateObject("MICentralAPICOM.MICentralAPI") oAPI.SetHost("localhost") oAPI.SetUser("miadmin") oAPI.SetPassword("password") If Not oAPI.Connect() Then WScript.Echo "Could not sign on to MOVEit Automation: " & oAPI.GetErrorCode() & ": " & oAPI.GetErrorDescription() Exit Sub End If WScript.Echo "Signed on to MOVEit Automation." & vbcrlf If IncrementCount() Then WScript.Echo "Successfully incremented global parameter ""NumberSeq""." End If End Sub Main Set oAPI = Nothing