Share via


%Filename% macro is not replaced with the disk filename

I've seen this issue showing a couple of times on the BizTalk Newsgroups so I thought it's worth posting about this on my blog. The user expectation, which is probably correct from usability point of view, is that the %Filename% macro is replaced with the name of the original file no matter if that file was received from the disk through FILE adapter or from a document library through SharePoint adapter. This doesn't happen like that since the WSS adapter send ports will resolve the %Filename% macro to empty string if the message was originally received from any other adapter than WSS adapter. This is by design.

The %Filename% macro is replaced with the name of the SharePoint file (and not with the name of a file on disk). If the message was received through FILE adapter (or any other adapter than WSS) then the %Filename% macro is probably replaced with empty string. Macros (like %Filename%) and context properties (like WSS.Filename) are implemented by each adapter separately, they are specific to each adapter, and there is no 'framework' that would provide a unified set of macros/context properties accross all adapters. This makes sense since '%Filename%' might not make sense for a POP3 adapter or it could have a slightly different behavior for 3rd party adapters. Coincidently, some adapters have used the same macro name (I would guess %Filename% is a common one) and ocasionally the same context property. However, the %Filename% macro in a WSS adapter send port is totally different from a %Filename% macro in an FTP adapter send port, for instance.

To workaround this you can use an orchestration or a custom pipeline. All you need to do is get the disk file name from FILE.ReceivedFileName property and save it in the WSS.Filename property like below. Make sure that the Filename field in the send port UI dialog box is left empty so that the value supplied through the context property WSS.Filename is used to set the filename.
   sharepointOutgoingMsg(WSS.Filename) = diskIncomingMsg(FILE.ReceivedFileName);

https://msdn.microsoft.com/library/en-us/BTS06Operations/html/1ff50fb8-7ba0-47b8-9476-d57413989346.asp?frame=true
https://msdn.microsoft.com/library/en-us/BTS06Operations/html/c5ae5339-67bf-4fde-a721-5b1aa3b9caca.asp?frame=true

You don't have to use dynamic send ports for the workaround above. In the case of WSS adapter, you can define the send port configuration through the WSS.Config*, WSS.Filename context properties of the outgoing message and then configure the WSS send port equivalent properties so that they are either empty (text boxes) or have a value of Orchestration (drop-down boxes) in order to not overwrite the configuration information specified through the context properties.

Comments

  • Anonymous
    July 10, 2006
    It seems relatively easy to do this within an orchestration, but I am not so sure how to do this with a custom pipeline. Do you have a custom pipeline example that does this? Thanks.
  • Anonymous
    July 10, 2006
    I don't have a sample but I'm pretty sure you will find at least a few custom pipeline samples outthere if you search on the Internet.
  • Anonymous
    July 11, 2006
    The comment has been removed
  • Anonymous
    July 11, 2006
    You have only one message diskIncomingMsg that is modified in the pipeline, you don't have nor do you need two messages. The WSS adapter uses the filename from the WSS.Filename context property. The only thing that you need to do in your receive pipeline, is to modify the diskIncomingMsg and copy the 'filename' value from the FILE.ReceivedFileName to the WSS.Filename context property. When the message exits the pipeline, the filename value will be present in both context properties. You will use IPersistPropertyBag.Load to load the filename value from the FILE.ReceivedFileName context property and then you will use IPersistPropertyBag.Save to save that value in the WSS.Filename property.
  • Anonymous
    September 04, 2006
    The comment has been removed
  • Anonymous
    September 05, 2006
    You can use BizTalk MMC to discover the namespace and all other details for adapters property schemas and more.

    Under BizTalk Group -> Applications -> BizTalk System -> Schemas, you will find the WSS.bts_WindowsSharePointServices_properties XSD schema that defines the WSS adapter namespace and properties.

    The property schema namespace for WSS adapter is 'http://schemas.microsoft.com/BizTalk/2006/WindowsSharePointServices-properties'
  • Anonymous
    December 10, 2006
    I have created a simple orchestration to pass filename to wss adapter.I works ok for most file names. I know, not all NTFS file names are valid for sharepoint. But there are some files which i can upload manually but wss adapter appearently not."ShowTv.RingtoneDistributor.DebitProxy[13-15].rar" is not a valid value for the 'Filename' property. Windows SharePoint Services file names can not contain more than one '.' character.Is this a bug in wss adapter? How can i convert file names to be sharepoint compatible?
  • Anonymous
    December 12, 2006
    The comment has been removed
  • Anonymous
    April 07, 2008
    I have the same problem with the Macro %FileName%.But the links( http://msdn.microsoft.com/library/en-us/BTS06Operations/html/1ff50fb8-7ba0-47b8-9476-d57413989346.asp?frame=true )you gave have been replaced ( or not available ). So please can you give me alternative links ..??Thanks…Asif Azad
  • Anonymous
    April 07, 2008
    Try these links:WSS ADAPTERhttp://msdn2.microsoft.com/en-us/library/aa558724.aspxhttp://msdn2.microsoft.com/en-us/library/aa547920.aspxALL ADAPTERShttp://msdn2.microsoft.com/en-us/library/aa578103.aspx