How to extract a item from compose.
For example I have a compose item like below,
How to get "AAAA" only and input create a item to sharepoint List.
I tyied
outputs('Select')?['Title']
Appear Error msg like that "Array elements can only be selected using an integer index."
Compose
{ "Titile" : "AAAA",
"TitleB" : "BBBB",
"TitleC" : "CCCC",
"TitleD" * "DDDD}
Firstly, your JSON is far from being valid so I've made some assumptions and have included it here with what I used for my answer ...
{
"TitleA": "AAAA",
"TitleB": "BBBB",
"TitleC": "CCCC",
"TitleD": "DDDD"
}
My suggestion is that you use variables instead of compose.
Here is my flow ...
With the second step, this is the expression I used ...
variables('Json Object')?['TitleA']
This is the end result ...
Related
I have the following JSON file which will be passed as a parameter file to an Argo workflow:
{
"keys": [
"key1",
"key2",
"key3"
]
}
Accessing "keys" like '{{inputs.parameters.keys}}' reads keys as a string instead of a list.
Is it possible to read an input parameter from a parameter file as a list of values?
Within an Argo Workflow, parameters are always strings.
You can use expression templates to retrieve information from the stringified list.
value: '{{=jsonpath(inputs.parameters.keys, "$.0")}}' # get the first item
How can I use MS Flow to select an individual object, by value for a specified property, from an array?
Example array:
[
{
item_id: '1234'
},
{
item_id: '4567'
}
]
In the example above, I may only want to work with the first object and the rest of its available properties.
Happy to use the Workflow Definition Language and/or any of the Data Operations actions.
I solved this by using the "Data operations - Filter" action.
Ignore the error in red - it is an array.
My left-hand expression for "item_id" is:
item()?['item_id']
And then I statically enter the item ID I wish to access in the right-hand input.
DocumentNo Item will then be an array itself with only 0 or 1 elements and can be used like so:
body('DocumentNo_Item')?[0]?['label']
I have a problem with a Jinja2 template I'm writing (called from Ansible).
The resultant file is a JSON file that I will send to an API (either with Ansible URI module or with curl). The template looks like this and basically works:
{
"description" : "my description",
"pipeline": "{% include 'root/pipeline.j2' %}"
}
The problem is that the content of root/pipeline.j2 is quite complex and includes multiple lines, quote characters and any number of other things that make the json file I'm creating invalid. What I want to do is parse the included file through a filter to convert it to a JSON valid string; something like this:
{
"description" : "my description",
"pipeline": "{% include 'root/pipeline.j2' | to_json %}"
}
But that doesn't work, probably because the filter is acting on the filename, not the included content.
Just for a little clarity when I create the template at the moment I see pipeline gets set to something like this:
"pipeline": "input {
"input1" {
<snipped>
"
It should appear thus:
"pipeline": "input {\n \"input1\" {<snipped>"
NB: I'm only giving the first couple of lines and I am using 'snipped' where I have remove the rest of the config.
Can anyone tell me how I can use an include within a jinja2 template that renders the result as a single line valid json string?
Thanks in advance for any assistance.
I finally managed to find a solution to my own question. Within the template that provides the JSON that is an API payload I am now setting a variable to the content of the pipeline template, which makes it easy to filter it with to_json:
{% set pipeline = lookup('template', 'root/pipeline.j2') %}
{
"description" : "my description",
"pipeline": {{ pipeline | to_json }}
}
I will leave this quesiton answer open for a while in case anyone can supply a better answer or explain why this is not a good one.
Thanks.
What is the proper way to achieve the visual equivalent of this:
, but for an array that is part of the entity of the Resource itself (as opposed being a field on a referenced entity)? For instance, if my document looked like {"id": 1, "title": "my title", "comments_by": ["john", "kate"]}.
I tried to nest a List element but wasn't able to make it look right.
You're on the right track; This should achieve your goal:
<FunctionField render={record=>
record.comments_by.map((by,index)=> <ChipField record={{by}} source="by"/>)
}/>
Hi I've a puppet template with below values.
myfile.erb
name = "abc"
desg = "engineer"
Sal = "10000"
And I try to read these values from my puppet script like below
init.pp
$value = template("d:/puppet/modules/mymodule/templates/myfile.erb")
now my $value is containing all values from the myfile.erb file. Is there any way to divide the values like $value[0], $value[1] etc..
I want to display only "abc" "engineer" "1000"
When your data lookup starts getting complicated, I highly recommend you move away from templates towards an external data lookup, like hiera. For a guide to setting up, I've written a small tutorial here. You can substitute yaml for json.
Your hiera file could look as simple as this:
{
"myfile": {
"name": "abc",
"desg": "engineer"
"Sal": "10000"
}
}
And then in your file:
$vars = hiera('myfile')
// Gives "abc"
$vars['name']
// Gives "engineer"
$vars['desg']