Binding JSON Data to a Clarify control using ClearBasic
A while back, I posted some information on how to consume JSON data in ClearBasic.
Someone recently asked me if you could bind a set of data from a web service into a Clarify grid. Of course. Similar idea to what I posted earlier, just now we want to take the object that we created from the JSON, and turn it into something that the Clarify UI can consume. For a Clarify grid, a list of records will work.
I created a simple web service that returned a collection of data in JSON format. To be honest, I used the Dovetail SDK to query for a list of the user’s open cases, and return it in JSON format. But the web service could return any data, from any source.
Here’s the basic code:
What’s happening here?
We loop through the results from the web service. For each one, we create a new record, and add that record to a list. Then we return the list of records
Fill the Cobj
Now that we have a list of records, we simply fill that list of records into a contextual object, as shown in the first code snippet.
Filled Clarify Grid
And our form renders the data:
The complete form code is on github: https://gist.github.com/925692
Now that you know how to consume JSON from ClearBasic, and bind it to Clarify UI controls, you can consume data from all sorts of sources, including many web services, and have it render inside of the Clarify Client.