How to retrieve saved documents

When a trading partner sends a document to your TN instance, you receive it, recognize the doc type and as one of the options on that doc type you save it to the database (contents, attributes and activity log) how can you later from a different flow service retrieve that document?


You can use and :documentQuery to retrieve docs from the TN database.

Thanks again Rob!

Hey, is there any “Best practices” as far as, what data is used as the key to write your query against?

I am guessing, in the identifing query of the doc type, what ever I set my documentID to, if it is unique, can be used to query agaist later?


That’s correct. Anything you can do with TN Console you can do in a FLOW service to retrieve the bizdoc of interest.

Rob, so after you execute documentQuery, you will be returned a recordList:results. Is the content part of the document suppose to be return in the is result record list?

I can query the db and see that I am getting the document I want but in the results rec list, I get a single record containing the follwoing elements: SenderID, REceiverID, DocCount, ErrCount. I want to get the document out of the DB and back into a record, so I can map from it.


The DocID field that is returned in the results is the internal TN document ID. You can pass this to to get the bizdoc and content. With that you can convert it to a record and do your mapping.

Thats what I thought, I found the and :getContentPart services, I wasn’t sure which one would be better to use.


Rob, I have hit this problem before and got around it, since I am fighting this again, I thought I would ask.

When you get the results record List return from the, I can not expand that record list to see the elements in the list. When I loop over the list, I still can’t see the elements in the record[0]. The results window show me there is a DocId, DocTimestamp, TypeName, SenderCorp, etc… but how do you access them, when they are not visible in the developer?


Yeah, kinda funky that they don’t define a record to help. But here’s how to do it:

  1. Add the invoke step to invoke view after your documentQuery step.
  2. On the Pipeline In, click on the results var.
  3. Click the Insert button on the pipeline toolbar to insert a new String. Name the new var “DocID” and press Enter.
  4. Click the Shift Right button on the pipeline toolbar to move the DocID var under the results var. Basically, you’re defining the expected record fields on the fly.
  5. Map the DocID to the internalId parameter.

If you are positive that you will always get only one entry in the results list, then you’re done. If you might get mulitple entries, you can set the index of the map to use the 0 entry from results. Or you can loop over results.



I did a similar thing, basically I copied the result record[0] from the results tab on the developer and pasted in my pipeline in on the flow step where I invoke :view and then mapped the DocID, which was visible now to the internal ID. This should be basically the same implementation that you are describing. oh, yes I am expecting 1 result so I have set the index to 0.



I was looking at some posts and I saw this one. If you are still facing the problem then I figured what was wrong here!

In your last post you said you copied the result record. Donot copy the result record, just copy the DocID field. Then this will work. Also since result is a record list, it is advisable to loop over the whole result reclist and then put this step.
Hope this helps.


How can you query for a document using createdocumentquery and documentquery, when all you have is the documentID and the conversationID? I have several documents in TN that have the same documentid, what make the document unique for me will be the conversationID in where the document was used. I have tried to use the attribute record as part of my search by setting the Attribute name to ConversationID, but that will result in an error, unknown attribute. Does anyone know how you can search for a document by docID and converstaionID?



Try using:
wm.tnweb.querySvc:getDocuments (in the WmTNWeb package)

Use the parameters:
ConversationID and NativeDocID

(You can use wm.tnweb.querySvc:getDocuments to get the content from the DocID).

  • Piara