I'm wanting to pass json format file into a CDT and ultimately into data store using the Write to Datastore Smart Service.
What's the function I need to write as per below so that I can make this work ? Can't work out how to get from json into Dictionary or List format which seems to be required ?
Discussion posts and replies are publicly visible
Have you tried experimenting with a!fromjson()?
https://docs.appian.com/suite/help/19.3/fnc_system_a_fromjson.html
Thanks, exactly what I needed.
Another query ... what am I doing wrong. When writing to the data store the records are not being split into separate rows but joined together in a single cell ? When using the Write to Datastore Entity / or do I need to use the Write to Multiple Data Store Entry ?
You never really specified what the format/structure of your original JSON string is. Basically you need to make sure that when you pass such string into a!fromJson, it returns an array of dictionary (as opposed to, for example, a flat array of strings or something).
For troubleshooting / testing you should try this in a blank Expression Rule editor and see what the result is. Additionally you might try declaring a PV of your CDT type "iddcdt" (also multiple), and run the a!fromJson in a script task, saving the result into the PV, prior to the WTDS node.
stuartt0002 Can you explain the configuration you did here to push data into the database?
The basic answer is already there. What exactly are you looking for?
I'm a newcomer to the Appian platform, and I need guidance on uploading a .json file using a file upload component. The goal is to incorporate the file's data into the database. Here's a sample .json format:
{
"page.name" : "Home page", "page.nav.title" : "Appian community", "page.nav.button" : "Discuss"}
Could you provide a concise explanation on how can I go about achieving this task?
That's a nice challenge for a newcomer.
To be able to help you, I need to understand what you already learned. So, which of the following things do you already know?
- Store a uploaded file in a folder in Appian
- Create a record and store data to it
- Do all of the above in a process model
- Calling a record type constructor to create a new data structure
- Local variables in expressions
- Plugins
I did a similar challenge that involved importing Excel data into a database using a plugin (Excel Tools) and a smart service (“import excel to database”). I used concepts you mentioned, except for “- calling a record type constructor for creating a new data structure.”
OK. You need the plugin "Text File Utilities".
Then:
- Upload the file
- Then, in an expression with the uploaded file as a rule input
- load the JSON from the file (plugin function)
- convert it into an Appian dictionary using fromJSON()
- map the data to your record type (https://docs.appian.com/suite/help/23.4/reference-records.html#use-a-record-type-constructor)
- the record data is the output of the expression
- call this expression in a script task and store the output in a process variable.
- write the record