Retrieving the time stamp of the received message - biztalk

I could not figure how to retrieve the time stamp of the received messages. Based on the time the messages received I have to send emails to two different send ports. I understand how can I dynamically send the messages but dont know, how can I decide based on the time it arrives.
Can anyone help me with this. Thanks a lot.

Since you are using the File Adapter, you can read out the FileCreationTime Property of the http://schemas.microsoft.com/BizTalk/2003/file-properties NameSpace. This Property holds the DateTime when the file was created in the file location monitored by the adapter.
When you want the DateTime of the message when it was received in BizTalk, you should use the AdapterReceiveCompleteTime of the http://schemas.microsoft.com/BizTalk/2003/messagetracking-properties NameSpace.

There are several options:
Using the FILE adapter, you have a FileCreationTime property, set by the FILE adapter. This is not the timestamp of receiving, but might be sufficient for your cause.
If you need to have the EXACT timestamp when you received the file, you would need to create a custom pipeline component that either:
includes it in the message somewhere
or writes/promotes a property in the context of the message using DateTime.Now for example.
You can then use it in a mapping or content based routing somewhere.
I think these are your options.

Related

Issue with BAM Continuation for BizTalk

I have developed a BizTalk Application. It receives a xml file and, after applying the business logic, it sends the file to another location using FILE adapter. I need to track the start and end time for both Receive Port and Send Port. I have created BAM activities and view and have created a tracking profile using Tracking Profile Editor. I have used Interchange ID as continuation ID token.
The problem is that in the BAM tracking, I am getting two rows, one for the receive port and second for the send port. The continuation between the receive and send port is not working.
The Continuation is not working most likely because InterchangeID is not naturally Promoted.
The small issue you have is that there is no naturally Promoted Property that can be used out of the box for this.
The simplest solution would be to create a custom Pipeline Component that Promotes InterchangeID (same property, just Promoted). Then your Tracking Profile should start working.
FYI, it this point, you don't really need BAM as it's pretty easy to query tracking directly using the same Promoted Property (which is what BAM is essentially doing using a slightly different path).
The interchange id will be present in the message context. Can you please confirm you mapped receive and send ports to the continuations in the tracking profile editor. Refer the article https://www.biztalk-server-tutorial.com/2013/02/08/how-to-enable-bam-continuation-between-receive-send-ports-using-tracking-profile-editor/ which shows the steps to add continuation correctly.

How to retrieve filenames for a BizTalk Purchase Order

I am very much new to BizTalk Server, one of our clients want to know the filename of the purchase order given by them. Its already been processed in the system through BizTalk Server and the client has received the purchase order, but he wants to get the filename of that purchase order (or in short the whole file for that purchase order) as there was some issue with the cost.
How can I get it or what are the steps for doing it?
Note: I am new to BizTalk so not much experieced in asking questions related to it. But if you have any questions which I can answer, please feel free to ask.
If you want to get the received filename inside an Orchestration you need to use the message context property BTS.ReceivedFileName.
e.g.
FileName = MessageName(BTS.ReceivedFileName);
If you want to set the filename in a send port to the received filename (or rather to what is in BTS.ReceivedFilename as you can set it yourself) then you need to use one of the predefined send Macros, in this case %SourceFileName%
If you want to see the filename in the BizTalk administration console, then you need to look at the message context and look for the ReceivedFileName property.

Append invoice list EDI message on outgoing batch

One of our partners requires that a "summary" edi message is appended to any EDI invoice interchange (apparently known as "invoice list"). This message contains a reference that every individual invoice should have in an RFF segment, as well as the cummulated MOA values.
My question is: does BizTalk Server (in particular BizTalk 2009) provide a convenient way to append another EDI message to the outgoing EDI batch upon release? I cannot find anything on MSDN.
My current idea is to append it in the send pipeline of the port that will transmit the batch, but I really would like a more convenient way.
I'll put it this way, your Trading Partner has a rather unusual, perhaps unique, requirement that is itself inconvenient. So, sorry, there is no 'convenient' way to accomplish this in BizTalk, probably in any platform either.
Anyway, here's what I would do, or at least some things I would try.
Batch the Invoices normally, such as with the Batching Service.
Subscribe to the Batch with an Orchestration.
Map the Batch to the Summary, which ever transaction that is, but it has to be X12/EDIFACT.
Use a dual input Map to create the batch with the summary appended.
Send to Send Port with the EDI Assembler.
I'm thinking it would be easier to use a Custom Xslt for the appending Map. That would save you from having to create a Schema for the Batch message, which doesn't actually ship with BizTalk.
The Xslt itself would be pretty simple since you just copying the two Messages. FYI, the Batch Message Orchestration Type wold be Microsoft.XLANGs.BaseTypes.Any. You can't use XmlDocument as a Map source.
I had the same requirement once, but instead of one specific summary message, I needed to be able to have full control over the the order of the EDI messages in the batch.
This is how I solved this at the time: http://blog.codit.eu/post/2009/11/10/Outbound-EDI-batching-in-BizTalk-Server-2009.aspx
It does have some downsides, but it might be handy to know.

Is there a way to validate a a BizTalk HIPAA message before the disassembler?

We have a solution that receives HIPAA X12 files using the Multiple schema, then splits them and sends them on to the orchestration. Occasionally the client will send a file with a structural error somewhere in the middle, and the message will be suspended, but only after it's already send a few of the sub-documents on to the orchestration. This is annoying...
What I'd like to do is validate the entire message and suspend it before disassembling it into multiple messages... I know I could do this if I switched to the Single schema, or set Preserve Interchange, but then I have to deal with the splitting somewhere else.
Suggestions? Thanks.
Check the Them->You tab of the Agreement under Local Host Settings.
The default option for Inbound batch processing option is to "suspend Transaction Sets (ST/SE) on error."
Change to "suspend Interchange on Error" and test to see if that satisfies your requirement.
That should work unless the Trading Partner sends files with multiple Interchanges.

Outbound Map not being used

I have a receive port. It calls a stored procedure for transport, then the receive pipeline is just passthrureceive (I tried XMLReceive, but that caused many more issues). I have a send port that has the filter set so it picks up the type of the receive port. The send port has a map and send pipeline. The map maps the xml from the receive port to a flat file schema, and then sends it to it's location. THe send pipeline has a flat file assembler.
So the map never runs. I just get errors from the send pipeline saying it can't match the document. No it can't, because it wasn't mapped. I read that you need an XML Disassembler on the recieve pipeline of the receive location. I added that, and that just started destroying my messages. They just get turned into a blank message or just a " in the message. So the XML disassembler is clearly not working right. I'm not sure what to do at this point.
OK, I figured it out. I have to use the XML disassembler to make the map run. The reason it was erasing my messages is, well I don't know the reason, but when I set the schema to "elementFormDefault = Qualified", it worked. I'm not really sure what that did, as I really don't have a good understanding of the whole qualified message thing, but that was the problem for me.
There is a wizard in Visual Studio to help you create the schemas and bindings that you use to communicate with stored procedures. I guess you didn't use that? (Right click on the project, hit "Add", then "Add Generated Items", then "Consume Adapter Service")
I'm calling my stored procedure from an orchestration hooked to two way send/receive port. I'm using a custom WCF type port with XMLTransmit and XMLReceive for the pipelines. This seems to work fine. The caveat being it's always a bit fiddly getting WCF to work since there are so many options.
In order to map from one format to another on ports, you need to have MessageType promoted. In your case it can be accomplished by using XMLReceive on the receive pipeline.

Resources