Two Things Everyone Should Know About Returning Multiple Property Bags

When using a script data source to create multiple property bags (this can be useful, for example, when the data is fed into a performance data mapper; each property bag becomes a mapped performance value), there are two common mistakes.

  1. After creating the property bag, adding its property/value pairs, and adding the bag to the ScriptAPI object, be sure to destroy the property bag before reusing the object reference variable.
  2. Use the ReturnItems call at the end to return multiple data items. 

Lines of interest are highlighted below.  These are the most common mistakes around multiple property bags.

Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
with oBag
  .AddProperty ("PropertyName1", Value1)
  .AddProperty ("PropertyName2", Value2)
end with
set oBag = nothing
set oBag = oAPI.CreatePropertyBag()
‘ more logic and property additions here
set oBag = nothing

This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to Two Things Everyone Should Know About Returning Multiple Property Bags

  1. Unknown says:

    What does this command (set oBag = nothing) do? I never used this, but my script datasources works fine.

  2. Mike says:

    It\’s a cleanup step. It destroys the oBag object created in the CreatePropertyBag() call. It\’s not usually necessary, but I\’ve seen bizarre cases where this made all the difference between successfully submitting multiple bags and unsuccessfully doing it.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s