How to convert array variable from trigger to javascript array in dynaform panel? - processmaker

In Processmaker 3 I use Trigger to query the database and store the result in Array.
I want to use this array in Dynaform panel control as a Javascript array so I can display it using Javascript.
How I can Convert it from normal PHP array to javascript array?
I attempted to use JSON convert functions but it never worked for me.

hidden : https://forum.processmaker.com/viewtopic.php?t=437
in a trigger pass #=hiddenFieldName to result of query
then use hiddenFieldName value with :
$('#hiddenFieldName').getValue()

Related

Qmetry- How to store and access Array of array list of strings

In Qmetry,Trying to save array of arraylist string and access same in another test case.
Array of array list :
ArrayList<ArrayList<String>> my_list
store(my_list, "array_list_1");
//Accessing saved list
Object list_details = getBundle().getObject(array_list_1);
System.out.println("++++ saved list details++++" + list_details);
I am able to print list_details content. Till this there is no issue. But when I try to get the first index within the arraylist, not able to use .get(0) method. Below is the code.
ArrayList<String> list_details1 = list_details.get(0);
When tried typecasting , got an error 'java.lang.String cannot be cast to java.util.ArrayList'
typecast:
ArrayList<ArrayList<String>>list_details1 = (ArrayList<ArrayList<String>>)list_details;
Need to know is it the right way to store and access arraylist ? Please suggest.
if you want store in file, you can use .csv or .xls to save ArrayList<ArrayList> my_list, if ArrayList<ArrayList> my_list you query from database, you can set as static variable, then you can use in different method

Return response as array instead of as an object in Contentful

I need to receive an array of objects as response from Contentful API. I tried to use "?select=fields" but that again returns an object with property items which is an array. I want to get the items array directly as a response is there a way to do this?
I don't think that's possible with the Contentful API. To my knowledge, it always returns items.

Getting certain key of returned JSON after using IMPORTDATA function

I am calling this url using the =IMPORTDATA() function and I am getting the following JSON back:
{"ETH":{"BTC":0.002616,"USD":1.13}}
How can I visualize only the value of the USD key in the cell?
I'm sure there is an easier way, but this will do it:
=index(split(substitute(index(importData("https://min-api.cryptocompare.com/data/pricehistorical?fsym=ETH&tsyms=BTC,USD&ts=1452680400"),0,2),"}}",""),":"),0,2)

How to convert JS array to JSON, before passing that to controller (using AJAX - POST call)

I ve a JS array, comprising multiple JS objects.
I want to convert JS array to JSON type, & pass that to controller (using AJAX - POST call).
So that I can retrieve the values from the Array of Objects, in my controller & save them in DB.
NB: I ve tried using $.stringify(myArry), but its not able to send data to controller in JSON format. Also I cant use $.toJSON(myArray), as I m not allowed to include a new plugin in our solution. :(
Plz suggest me any other idea.
Else if anyone can let me know how to deserelize the array in cotroller, that I ve sent by using $.stringify(myArry), that would also great.
Something like
var result = JavaScriptConvert.DeserializeObject(inputContent, JsonDataType);
Per this post, it looks like you'll have to add another plug-in:
JSON stringify missing from jQuery 1.4.1?
The Google solution looks good: http://code.google.com/p/jquery-json/
Or just use the JSON object from Crockford: https://github.com/douglascrockford/JSON-js

Translating javascript json parse to rails

I had to change an application that was making a call clientside (JS) to get back data that comes back as JSON. I had to move the call server side, and I'm using rails to return the data.
To reference the object I need, with the object being returned called "data" I was able to call it JS like so:
data.photos[0].tags[0].mouth_left.x
I'm very new to rails, I have the call populating a variable called face_values, I think I should call to_json on it next, but how do I reference the arrays and nested objects within?
Even a point in the right direction would be great, thank you.
parsing JSON in Rails is as follows:
parsed_json = ActiveSupport::JSON.decode(your_json_string)
or check out this link
They claim they are 21.5x faster than ActiveSupport::JSON.decode

Resources