Using option parameters

How to use parameters in Python script

In Web Assembly environment, the options values can be accessed inside python code via the global dict args. For example you have defined following options with specified value:

--vendor=vendor_0000

To access this option value inside the python code you could use args.get("vendor")

'''
This example is based on the Demo instance 
https://xoebp.xplain-data.com/objectexplorer/index.html
'''
import xplain   

# replace url with your currentObject Analytics host
x=xplain.Xsession(url="https://xoebp.xplain-data.com")

# or if you're running your XOE on your local host, 
#just use: 
#x=xplain.Xsession()

vendor_parameter = args.get('vendor')


x.open_attribute(object_name="PurchaseDocument", 
    dimension_name="Vendor", 
    attribute_name="Vendor")


x.run({
     "method": "select",
     "selection": {
         "attribute" : { 
             "object" : "PurchaseDocument", 
             "dimension" : "Vendor", 
             "attribute" : "Vendor" },
         "selectedStates" : [vendor_parameter]
    }
})

A section will be put on the state "vendor_0000".

Last updated