Number of results from AQS

Hi,

Using the examples from the help pages, I’ve been able to create workflow that will add assets as a parent item if they are within a buffer of the trigger item.

This is done by converting to BNG, creating the buffer, converting back to WSG84 and building an AQS query to look for assets that GeomIntersects the buffered geom.

Is there a way to return only 1 result from query.
Maybe returning the result of the AQS as a variable and returning a single value from that variable ?

Ideally I’d like the query to return just the nearest, but I can’t think of a way of doing that.

vars =[ {
    "name": "aqs_string",
    "value": {
      "script": "string json = @\"{'type': 'Query','properties': {'attributes': [],'collectionCode': ['Live'],'dodiCode': 'designs_adoptedNetwork_5ec939adddf8ae005bbc5d02'},'children': [{'type': 'GeomIntersects','children': [{'type': 'Attribute','properties': {'attributeCode': 'attributes_itemsGeometry'}},{'type': 'Geometry','properties': {'value':\"+ geometry_string+\"}}]}]}\"; return json.Replace(\"'\",\"\\\"\");",
      "discriminator": "WorkflowSyntaxNodeScriptWebModel"
    }
  },
  {
    "name": "aqs_json",
    "value": {
      "script": "var o = JToken.Parse(aqs_string); return o;",
      "discriminator": "WorkflowSyntaxNodeScriptWebModel"
    }]
parameters = [
    {
      "attributeCode": "attributes_workflowQueryActionsAqsQuery",
      "value": {
        "script": "return Aqs(aqs_json);",
        "returnOptions": {
          "dodiCode": "designs_adoptedNetwork_5ec939adddf8ae005bbc5d02",
          "discriminator": "DodiAttributeOptionsAqsWebModel"
        },
        "discriminator": "WorkflowSyntaxNodeScriptWebModel"
      },
      "discriminator": "WorkflowComputedItemAttributeWebModel"
    },
    {
      "discriminator": "WorkflowConstantItemAttributeWebModel",
      "attribute": {
        "attributeCode": "attributes_workflowQueryActionsSingleInstance",
        "value": False
      }
    }
  ]