Hey guys! How’s it going?
I’m trying to find a request-less solution using !save but I didn’t understand how to use it.
Here is a piece of code from my custom app
"select": {
"label": "Select",
"description": "Select a specific event",
"describe_selection": {
"resource_id": {
"!jq": ""
},
"display": {
"!jq": ""
}
},
"form_fields": [
{
"label": "Choose Resource",
"type": "dropdown",
"id": "resource",
"placeholder": "Select Resource",
"options": {
"!pipe": [
{
"!http": {
"method": "GET",
"path": "apps",
"params": {
"app": "62178c096669bd328fa070bb"
}
}
},
{
"!jq": "[.resources[] | {display: .label, value: .name}]"
}
]
}
},
{
"label": "Choose Event Type",
"type": "dropdown",
"id": "event",
"placeholder": "Select Event",
"options": {
"!pipe": [
{
"!http": {
"method": "GET",
"path": "apps/resources",
"params": {
"app": "62178c096669bd328fa070bb",
"resource": "${custom_data::resource::value}"
}
}
},
{
"!jq": ".resources[] | [.events[] | {display: .label, value: .name}]"
}
]
}
}
]
}
As you can see, I make a request of each field in order to get the values but the values to use on the second request are included on the request made on the first field.
Here is the result of the first field request:
{
"_id": {
"$oid": "62178c096669bd328fa070bb"
},
"schema": "2",
"name": "engagement",
"resources": [
{
"name": "engmt",
"label": "Engagement",
"events": [
{
"name": "snt",
"label": "Enviados"
}
]
},
{
"name": "engmt2",
"label": "Engagement2",
"events": [
{
"name": "snt2",
"label": "Enviados2"
}
]
}
]
}
For the second field, I just need “events” array from the selected source and I can get this using jq, but I would need to save the first request to be able to access the information later.
This is what I tried but didn’t worked:
{
"label": "Choose Resource",
"type": "dropdown",
"id": "resource",
"placeholder": "Select Resource",
"options": {
"!pipe": [
{
"!http": {
"method": "GET",
"path": "apps",
"params": {
"app": "62178c096669bd328fa070bb"
}
}
},
{
"!jq": "{resources: .body}"
},
{
"!save": {
"scope": "application"
}
},
{
"!jq": "${data::application::resources} | [.resources[] | {display: .label, value: .name}]"
}
]
}
}
Any suggest?