Hello there!
I am trying to put data from bigquery response API, into a table to create record types.
So far, I have been able to get the response from bigquery and convert it to appian values, the response looks like this:
then, I created a rule to narrow down to the values, but as you can see, the column name does not come from the response, so it displays all the values as rows but on the following way :
so as you see, I do not have columns there , I guess the best way to go on this, will be to get the JSON response converted to an array, and then pass it to a table but not sure if this is possible, any advise?
Discussion posts and replies are publicly visible
Do the column names come back somewhere else in the API response, or are you just expected to know them?
Either way I suspect you'll have to loop over the response rows and manually construct the necessary dictionary from each row's results. If each row will always have the exact same number of columns and you can just hardcode the column/property names, then this should be pretty easy. If there's an expectation that the columns might be variable and/or will need to be named after data that's given in another part of the response, then it's still doable but might be a bit harder.
Hello, thanks for your response.
From this response from bigQuery no, the column names do not come in the response anywhere, for that, you need to do another request on a different API from bigquery.
I get what you are saying of doing a loop, however, I have not found a way to create a table or a way to use loops, is it like on the interfaces or somewhere on the design pane?
I just mean that you'd loop over the response rows in your handler Expression Rule and create a formatted dictionary that gets passed back to wherever you need it. For starters:
createDictionary( {"State", "Country", "Type", "Date"}, { "Cali", "Argentina", "AA", today() } )
If you're willing, do me a favor and show your API output as "expression", and copy and paste here with the first ~2 or 3 rows worth of data (feel free to sanitize any of it as necessary, i just need the basic structure). I'm trying to assemble an example expression to try to loop over the rows and create dictionaries, however Appian doesn't easily allow for creating arrays-of-arrays like your output contains, thus at this point I'm hitting a dead end.
Thanks a lot Mike, sure thing, here is the requested information:
{{f: {{v: "Cali"}, {v: "country"}, {v: "AA"}, {v: "1/22/2021 11:47"}, {v: "5/11/2021 13:33"}, {v: "Match Sent"}, {v: "ZR_11607_CAND"}, {v: "5.09e+17"}, {v: "source"}}},
{f: {{v: "name"}, {v: "country"}, {v: "AA"}, {v: "3/22/2021 15:51"}, {v: "5/11/2021 13:16"}, {v: "Pending"}, {v: "ZR_12952_CAND"}, {v: "5.09e+17"}, {v: "source"}}}
{f: {{v: "name"}, {v: "country"}, {v: "AA"}, {v: "3/8/2021 11:20"}, {v: "5/11/2021 13:18"}, {v: "Proposed"}, {v: "ZR_13933_CAND"}, {v: "5.09e+17"}, {v: "source"}}}
I am working on using a data type, I was able to show now the correct column names, now I am just trying to figure out how the foreach syntax works in Appian (I'm new here) so maybe that will do it too
I believe it would end up being something along these lines, plus or minus:
a!forEach( rule!bigQuery().result.body.rows, createDictionary( {"State", "Country", ...}, /* array of all column/property names */ fv!item.v ) )
Thanks Mike,
I tried this code
a!forEach( rule!TGSU_bigquery().result.body.rows,
createdictionary({"Duckling", "Country", "Job Type","History created time", "Last activity time", "status","candidate_id","candidateID","source"}, /* array of all column/property names */ fv!item.v))
but it returns an error saying ' Expression evaluation error at function a!forEach: Error in a!forEach() expression during iteration 1: Expression evaluation error at function 'createdictionary' [line 4]: The list of keys and values must be of the same length. Recieved 9 keys and 1 values.'
then I guess is because I only added an 'fv!item.v' but if I add more, then I still get an error saying unexpected number of parameters
Please try running just this much, and seeing what the output is / what it's formatted like:
a!forEach( rule!TGSU_bigquery().result.body.rows, fv!item)
It returns the same thing as the response from the API from bigquery
I tried creating a type data, like a CDT and it shows this on a grid
however, to loop into it, do I use something like
'type!{urn:com:appian:types:TGSU}TGSU_tabletest'(),
I tried to use the code above but may have syntax errors, but not sure if I'm on the right way?
how about "rule!TGSU_bigquery().result.body.rows.f"?
I tried that, butt it returns the values on 'v:' I showed before :( is there a way to get a tutorial or something on converting JSON to array or to values to put into a table?
rodrigoe0001 said:butt it returns the values on 'v:' I showed before
I expected this, I was just curious to see the overall shape of the data when it's called that way.
What i'm hunting for here is how exactly we can refer to the dictionary value within your a!forEach() loop and effectively grab the array of deepest "v:" values, a group at a time, to convert to the dicitonary.
Yeah, that is exactly what we need, I am doing some testing now but I think this may not be possible as I'm encountering a lot of limitations, probably I will need to workaround it , please let me know if you find a way on doing that.
Try these permutations, just in case, and see if either happens to work any better:
first:
a!forEach( rule!bigQuery().result.body.rows.f, /* adding ".f" at the end here */ createDictionary( {"State", "Country", ...}, /* array of all column/property names */ fv!item.v ) )
Second, somewhat more radical:
a!forEach( rule!bigQuery().result.body.rows.f, createDictionary( {"State", "Country", ...}, /* array of all column/property names */ a!forEach( /* create an inner forEach loop, attempt to loop over the inner array of dictionaries containing the "v:" property */ fv!item, fv!item.v ) ) )