inject/create a freemarker variable from a WI

372 views
Skip to first unread message

J.M.

unread,
Jan 20, 2016, 4:06:58 AM1/20/16
to Fujitsu RunMyProcess Developer Community
Hi,

I'm building a little appication in which I need to make a load from a collection from the very beginning (before the process start) so I'm making the query from JS in the WI. However I will need the data loaded foreward in the process, and I was wondering if is there any way of achieve this.

I know the RMPApplication.get/set but this only works with widget variable.
I've thought some solutions like:
- add an invisible widget to the WI and use the RMPApplication.set function to put the value into it, and use it after, but the result of my load query is a JSON object, and if I choose this solution, i lose the JSON type, and I get the result like text cause there is no "JSON widget".
- The second option is to make the query twice, the first one in the WI, and the second one in the process, but making exactly the same query (same options, same collection and same query).


Is there any function that let me inject a javascript variable (JSON) into a freemarker variable in JSON? Which one?

In case the answer is negative, Sholud I make the query twice?

Thanks in advance and regards.

Murali

unread,
Jan 20, 2016, 7:11:31 AM1/20/16
to Fujitsu RunMyProcess Developer Community, javiermm...@gmail.com

 

Hi Javier, 


You can query back result from collection using JS (listCallback())in the WI and store those retrieved data in a variable(say test) using RMPApplication.setVariable() function, which will be accessible throughout process.


In process, you can use P_json_put() function to store in JSON format. Refer - http://docs.runmyprocess.com/API_Reference/FM/Utilities.html#P_json_put


For e.g  :

<#assign my_object ={}> 
<#assign my_object =P_json_put(my_object,"name_of_field",test)> 
${my_object}


Alternatively you can do this in JS using  :


var my_object={}; 
my_object.approver = result[i].field_name_from_collection; 
RMPApplication.setVariable("test",my_object); // test is a variable


Regards,

Murali

Reply all
Reply to author
Forward
0 new messages