How to read and write data to and from a JSON document?

Here is the scenario. The user has the ability to filter data on a report (multiple selection dropdowns) and they want to be able to save such filters so when they come back they see the same data again. I have a cdt where I save the filters so each cdt field is a filter on the front end. This cdt doesn't have a corresponding table since that wasn't written to the database. Now that I need to save the filters I thought about writing to a table, but the problem is that the cdt fields store multiple values and the columns on a table don't take multiple values. 

My idea was to write the filter cdt into a json doc and read back to sow the filters. But I've been looking around and I can't find a way to read or write documents within Appian. I thought about using the Excel plugin instead but it's now deprecated and the other one left needs a datastore to read from. 

The function document() only gives me metadata and nothing else. Has anyone done this before or have nay pointers to look into?

  Discussion posts and replies are publicly visible

Parents
  • You will definitely need a database table to store the saved filter - that's the only way you can save the information for when you come back to it later. You might have seen the recipe here for saving filters to a database table. However, you're also right that it's more complex when saving multiple values. One thing I have done before is to convert the list of values into some kind of list that can be stored in a single field; for example, you could convert the list of values into a semicolon-separated text value when saving to the database. Then, when you retrieve the data back from the database, split the data back into a list using the semicolon separator.

    Your idea for using JSON can also work - you could store the JSON string directly as a field in your database table, and then convert the data back to a list in Appian. There is an app in the app market for the Saved Filters Application that does something similar to this.

    In general, I'd suggest one of the two options above that use a database table rather than writing to a document directly, because the document will be much more difficult to parse and the database will perform better.

  • Peter, Storing the cdt filter as a json string in the table is best approach here. Converting between the 2 isn't difficult.

Reply Children