Triggering Script to Get Device List by Vendor

To query the database by defining an associate script and get a list of devices by vendor:
  1. Design a form using the following form fields:
    Field Name Field ID Type
    Select vendor type Dropdown
    Get device list get Button
    Select the device device Dropdown
  2. Define an associate script to get the devices and map the script to field Get.
    Script Description
    sys.path.insert(0,AVX::HELPER)
    sys.path.insert(0,AVX::DEPENDENCIES)
    
    import appviewx
    
    db_connection = appviewx.db_connection()
    device_collection = db_connection.appviewx.device
    

    ###Syntax to read any of the other form fields in the associate script -- '<field id>'##

    vendor = '<type>'
    device_list = [{"device":value['name']} 
    for value in device_collection.find
    ({"vendor":vendor,"category":"ADC"})]
    print(json.dumps(device_list))
    
    • Where type is input value from the form based on which the device(s) will be retrieved
    • device is the destination Field ID to which the list of devices are mapped back on the form.
  3. From the menu on the top, click (View) icon.
    The script is triggered to get the device list by vendor.