In Many situations we may have to save the file in the Output folder in a proper format.
BizTalk Send Port with File Adapter supports the following formats (macros) for the files saved.
Incase if we want the output file name to be some thing other than the available macros, we need to do some coding either in the Orchestration or in the Pipeline.
This Post will show you how you set the output file name in an Orchestration.
Scenario: Create a schema, receive a file of that type and set a name for the file and save it back to an output folder.
1. Create a sample schema in a BizTalk Project and add an Orchestration to the project.
2. Create two messages of the Schema Created in above step
3. Add a Receive, Message assignment and Send Shape as shown below.
4. Configure the Receive shape to Receive Message_1, set activate to true.
5. Configure the Construct Message shape to construct Message_2 and Send shape to Send Message_2. Resulting Orchestration should look like below.
6. Add the following code in the Message Assignment shape.
Message_2 = Message_1;
Message_2(FILE.ReceivedFileName) = “MyOutputFile”;
7. Add a receive and send ports and complete the Orchestration.
8. Deploy the Orchestration.
9. Configure the Send Port File Adapter as show below. (Change the file name to use %SourceFileName% Macro. (Case Sensitive)
10. Drop an instance of the Schema in the input folder, and see that the Output file name will be the same as what I have given in Step6.
The idea behind this is that, I have change the ReceivedFileName Context Property of the message received to my desired format and then I have used the % SourceFileName% macro.
The same can also be done using a Pipeline.
Hope it helps.