How to use unsaved settings values for exportSelect (supportsHandlebar)

Hi,

I’m trying to use the supportsHandlebar example from the Common Form Fields documentation, but it doesn’t seem to work.

https://docs.celigo.com/hc/en-us/articles/360059205112-Common-form-fields#UUID-6ce95fef-1430-cbc6-4dfe-e5f0285a0f8e_section-idm73515219760120

My use case is: I have 2 dynamic lookup fields: Companies and Customers. The Companies lookup will look a generic Companies list, and when I select a value for it, I would like the Customer list to update accordingly.

The Companies API endpoint is as simple as: /api/v2.0/companies

The Customers API endpoint, depends on the company value: /api/v2.0/companies(<>)/customers

But this doesn’t work. When I select a Company, I don’t know how to reference the Company Id that was selected on the 1st dynamic lookup.

Here’s my Customers exportSelect field, and I’m trying to reference my Company Id field by {{export.company}}, but it doesn’t seem to work, I keep on getting the error message “expecting array. try transform?”

Any insight here would be great! Thanks,

You're pretty close, but probably need a transformation to return the results correctly from the virtual export and to the form.

{
  "fieldMap": {
    "company": {
      "type": "exportSelect",
      "id": "company",
      "name": "company",
      "label": "company",
      "resource": {
        "virtual": {
          "name": "Get companies",
          "_connectionId": "6525a3099085040ecbf55b4d",
          "http": {
            "relativeURI": "/v2.0/companies",
            "method": "GET",
            "paging": {
              "method": "url",
              "path": "[@odata.nextLink]",
              "lastPageStatusCode": 404
            },
            "response": {
              "resourcePath": "value"
            }
          },
          "transform": {
            "type": "expression",
            "expression": {
              "rules": [
                []
              ],
              "rulesTwoDotZero": {
                "mappings": [
                  {
                    "generate": "value",
                    "dataType": "string",
                    "extract": "$.id",
                    "status": "Active",
                    "sourceDataType": "string"
                  },
                  {
                    "generate": "label",
                    "dataType": "string",
                    "extract": "$.name",
                    "status": "Active",
                    "sourceDataType": "string"
                  }
                ],
                "mode": "create"
              },
              "version": "2"
            },
            "rules": [
              []
            ],
            "version": "2"
          },
          "adaptorType": "HTTPExport"
        }
      }
    },
    "customer": {
      "id": "customer",
      "name": "customer",
      "type": "exportSelect",
      "label": "customer list based on company",
      "supportHandlebars": true,
      "refreshOptionsOnChangesTo": [
        "company"
      ],
      "visibleWhen": [
        {
          "field": "company",
          "isNot": [
            null,
            ""
          ]
        }
      ],
      "resource": {
        "virtual": {
          "name": "Get customers",
          "_connectionId": "6525a3099085040ecbf55b4d",
          "http": {
            "relativeURI": "/v2.0/companies({{export.company}})/customers",
            "method": "GET",
            "paging": {
              "method": "url",
              "path": "[@odata.nextLink]",
              "lastPageStatusCode": 404
            },
            "response": {
              "resourcePath": "value"
            }
          },
          "transform": {
            "type": "expression",
            "expression": {
              "rules": [
                []
              ],
              "rulesTwoDotZero": {
                "mappings": [
                  {
                    "generate": "value",
                    "dataType": "string",
                    "extract": "$.id",
                    "status": "Active",
                    "sourceDataType": "string"
                  },
                  {
                    "generate": "label",
                    "dataType": "string",
                    "extract": "$.displayName",
                    "status": "Active",
                    "sourceDataType": "string"
                  }
                ],
                "mode": "create"
              },
              "version": "2"
            },
            "rules": [
              []
            ],
            "version": "2"
          },
          "adaptorType": "HTTPExport"
        }
      }
    }
  }
}

All list options require some standard format which is why a transformation is needed to return a response such as:

"options": [
  {
    "items": [
      "Create",
      "Update",
      "Delete"
    ]
  }
]

or

{
  "options": [
    {
      "items": [
        {
          "label": "Delhi",
          "value": "Delhi"
        },
        {
          "label": "Hyderabad",
          "value": "Hyderabad"
        },
        {
          "label": "Chennai",
          "value": "Chennai"
        }
      ]
    }
  ]
}
1 Like

Hi Tyler, thanks for the answer. It does make sense what you said, but I literally copied your solution (which is very similar to the one on the help article as well), and I just replaced 2 things:

  • Connection ID
  • RelativeURI: In you example, your RelativeURI started with /v2.0, and I changed mine to include /api/v2.0 because my HTTP connector is connecting to a more generic Business Central URL

And still, I’m getting the same error message as I was getting before:

The moment I replace {{export.company}} with a hardcoded Fixed Id, then the list gets populated correctly.

Does it have anything to do with the Relative URI? Or the way my HTTP Connector is setup?

Where are you building this form? Is it on the integration level, flow group, flow, export, or import level? I suspect you might need to use {{integration.company}} or one of the others.

1 Like

That was it! Indeed, I had this form being built on the integration settings, not on the export. Thanks!

1 Like