TeamDesk Knowledge Base & Support

   Home      FAQ      Forum      Idea Exchange      Ask a Question      My Stuff      Help   
  
Importing of Json or XHML Files
All,
Looking for a solution to import JSON or XHML Files.
We have a custom built Billing platform that generates a file in JSON for all of our invoices for our customers(about 400 a day).
Currently we send that to our Payment processor who uploades that into thier printing system at sends out all of our invoices. Every customer we have has access to our Teamdesk system to look at account balances. i would like to upload the same Json file into our TD application so that customers can download the invoices should they need a copy. i have figured out how to do they exact same thing from other services that i can use the API to get the info as it comes in as a responce to a get command and i can process with iterators and get all the data i need. unfortunatly in this case the system has to API and can only export a file.
Has anyone done something similar and if so would you mind sharing the way they did?

Thanks
ID
1499
Category
Integration/API
Author

Mike Nelson
Date Created
1/26/2022 12:45:29 PM
Date Updated
3/14/2022 8:58:24 AM
Comments
Pierre 1/26/2022 1:00:11 PM
Hello Nelson
I am not sure to understand what you need.
Have you tried the TeamDesk Webhooks ?
Kind regards,
Pierre
Mila Shvets  Staff  1/28/2022 9:07:39 AM
Hi Mike,

I built the example in the "Import JSON or XHML Files" database free trial.
You'll receive the invitation to this example.

The main idea is the following:
In the "Files" table keeping records with File Attachments (.json or .xml files) I adjusted two custom buttons.
Each button sends files to created "JSON Webhook" or "XML Webhook" respectively.
These webhooks generate records in separate tables.
In the example the "JSON Webhook" generates records in the "JSON Webhooks" table, the "XML Webhook" - in the "XML Webhooks" table.
The custom buttons only demonstrate how the webhooks work.
You may read more about Webhooks here https://www.teamdesk.net/help/15.14.aspx

In your database you can collect invoice files (.json or .xml files) in the Mailbox table.
The Mailbox table can comprise a Record Change trigger with Call-URL action sending file data into webhook.
After that the webhook can create a record in a separate table.
More info on the Mailbox table you may read here https://www.teamdesk.net/help/15.5.aspx

If you don't want to use the Mailbox table, the files can be sent directly to webhooks created in your database, but in this case you will need more complicate programming.

Kind regards,
Mila
Mike Nelson 1/28/2022 10:42:57 AM
Thanks for the responce but i think i did not comunicate the goal.

i understand on how to process a webhook but what i am trying to accomplish is as follows
i will send a email to teamdesk with an attached file either XML or JSON(can do either one would prefer XML)
when that email arrives in teamdesk mailbox i would like to take the attachemnt Test.XML and process it as follows

Contents of the XML File

<Statements>
<statement>
<InvoiceNumber>123456789</InvoiceNumber
<CustomerName>AAA Company</CustomerName>
<DetailedCharge>
<EquipmentDescription>Water Machine #1</EquipmentDescription>
<Amount>100.00</Amount>
</DetailedCharge>
<DetailedCharge>
<EquipmentDescription>Water Machine #2</EquipmentDescription>
<Amount>100.00</Amount>
</DetailedCharge>
<Aging>
<Current>200.00</Current>
<over90Days>400.00</over90days>
</Aging>
</statement>
<statement>
<InvoiceNumber>987654321</InvoiceNumber
<CustomerName>ZZZ Company</CustomerName>
<DetailedCharge>
<EquipmentDescription>Cooler</EquipmentDescription>
<Amount>50.00</Amount>
</DetailedCharge>
<Aging>
<Current>50.00</Current>
<over90Days>0.00</over90days>
</Aging>
</statement>
</Statements>

I would like this to import into my system as follows
Table 1(Invoices)
would import
Record1 - 123456789 into Column "Invoice Number", AAA Company into Column "Customer" , 200.00 into Column "Current" and 400.00 Into Column "Over 90 Days"
Record2 - 987654321 into Column "Invoice Number", ZZZ Company into Column "Customer" , 50.00 into Column "Current" and 0.00 Into Column "Over 90 Days"

Table 2 (Invoice Detail)
would Import
Record 1 - 123456789 into Column "Invoice Number", Water Machine #1 into "Description" and 100.00 into "Amount"
Record 2 - 123456789 into Column "Invoice Number", Water Machine #2 into "Description" and 100.00 into "Amount"
Record 3 - 987654321 into Column "Invoice Number", Cooler into "Description" and 50.00 into "Amount"

Hopefully that clarifies what i am trying to get to.

Mike


Slava Shinderov  Staff  1/28/2022 11:55:56 AM
@Mike I took a liberty and altered a sample database created by Mila. I've added a mailbox table, which post fist attached file into Statements webhook which parse it and create records into Invoice and Invoice Details table with help of two iterators. Please review.
Mike Nelson 1/28/2022 1:08:42 PM
Thanks will give it a look
Mike

Mike Nelson 1/28/2022 1:12:25 PM
Slava,
That is exactly what i am looking for.

Thanks for the help

Mike
Mike Nelson 2/1/2022 8:32:07 AM
Salve,
Thanks for your hep all is working s expected... But of course we always want to go one step further. do you know of a way to change the import of data from a POST Curl to a PUT? reason for this is trying to make it so that when i import the data into the system i am hoping to be able to Update invoices that are already in the system rather than create new ones. I have come up with a work around by relating the invoices to each other based on the invoice number and taking the data from the newest created but it will cause us to have alot of extra data in our system.

thanks for your help

Mike
Pierre 2/1/2022 8:46:09 AM
@Mike
Check the method UPSERT in TeamDesk Rest API
Mike Nelson 2/1/2022 9:07:56 AM
@Pierre
Unfortunetly the webhooks look like it creates the POST Statement and i have not found a place to change the URL.

Mike
Pierre 2/1/2022 9:22:15 AM
I do not have access to Mila and Slava's table

To import data to TeamDesk, I understand you could either:

1) Use webhooks
- the webhook will create a record at each call in a table 1
- at each creation in table one, you can trigger:
a) a create action if Exists([your index in table 2]) is not true
b) an update action if Exists([your index in table 2]) is true

2) use a POST API Call
using the UPSERT method
something like:
POST
URL
https:// YOURAPPURL /secure/api/v2/<%AppId()%>/<%' YOUR TABLE NAME'%>/upsert.json

Header:
Authorization: Bearer YOURTOKEN
Content-Type: application/json

Body:
[
{
"dummy": 360,
"@YOUR INDEX": "YOUR INDEX VALUE"
}
]
Pierre
Slava Shinderov  Staff  2/1/2022 12:49:10 PM
@Mike by design, webhook always create records.
If you've need to update records please consider creating relation between newly created record and record you've need to update.
After that, using record change trigger on create with linked record update action you can update related record using reference or recordset column.
Mike Nelson 3/13/2022 10:25:04 PM
Slava can you give me access to this database again i would like to try a experiment in it but 14 days has passed.


Slava Shinderov  Staff  3/14/2022 8:58:24 AM
@Mikе I've extended trial period.
Feedback
Back to Search Results