A recent project I was developing I was required to pull data from either a file location or a FTP location, and based on the filename it was supposed to do something.

I started testing and I came across an XLANG/s error:

Shape name: Decide Type of Password Reset
ShapeId: 56e918c9-c009-4f4a-a722-a3f6c2f7dd55
Exception thrown from: segment 1, progress 15
Inner exception: There is no value associated with the property ‘FILE.ReceivedFileName’ in the message.

I had forgotten to change my code in the decision shape from testing just the File.ReceivedFileName to something more intelligent.

I started looking at how I could change the code. In this case I was pulling the data from an FTP location, so obviously, the FILE.ReceivedFileName did not exist in the message context. I thought of writing the code in an expression shape to be like this:

if(inputMsg(BTS.InboundTransportType)=="FILE") { filename=inputMsg(FILE.ReceivedFileName); } else { filename=inputMsg(FTP.ReceivedFileName); }

But I was not satisfied (am I ever?), I then looked at the XLANG/s operators and after reviewing the exists operator I came up with some different code:

if(FILE.ReceivedFileName exists inputMsg) { filename=inputMsg(FILE.ReceivedFileName); } else { filename=inputMsg(FTP.ReceivedFileName); }

Now there is no perceived benefit in using one way of extracting the filename compared to another, but it is just another arrow in the quiver.