Share via


Code to Create and Manipulate a Global Resource

In this example, a global resource is created for the site created in Code to Create a Site. Resource settings are retrieved, changed, retrieved again, and written to the screen. Create the example using the following Visual Basic code.

  1. Create the global resource. The schema class name is "MSCS_Predictor", as this example is creating a Predictor resource. After the resource is created, save the configuration settings.

    Dim oPredictor
    oGlobConfig.CreateServiceConfig "oPredictor", "MSCS_Predictor"
    oGlobConfig.SaveConfig
    
  2. Retrieve and change a property in the Predictor resource at the global level. This property, on creation, defaults to True. It will be retrieved, displayed, set to False, retrieved, and displayed again.

    Dim x, y
    Set x = oGlobConfig.Fields("oPredictor").Value
    y = x.Fields("f_UseExternalDB").Value
    MsgBox y, , "f_UseExternalDB value before change"
    
    ' Assign a new property value
    y = False
    x.Fields("f_UseExternalDB").Value = y
    ' Save the settings
    oGlobConfig.SaveConfig
    Set x = oGlobConfig.Fields("oPredictor").Value
    y = x.Fields("f_UseExternalDB").Value
    MsgBox y, , "f_UseExternalDB value after change"
    


All rights reserved.