A situation arose where it was necessary to find the number of attachments on a ListItem in a list.
SharePoint makes available the Lists web service, and exposes a method called GetAttachmentCollection.
We are able to use the Call Web Service action to retrieve the attachments (urls) in an XML format.
Drag a Call Web Service action to a pearl in your Workflow. Configure it to the Lists webservice : http://<server>/<site>/Lists.asmx. Provide the appropriate credentials, and click on the Refresh button to retrieve a list of available web methods exposed by the Lists web service. From the lists, select GetAttachmentCollection . In the parameters, you can click on the Insert Reference buttons to pick List Name from the Common properties and ID from the Item properties.
Set the "Store result in" to a text Workflow variable, and the Result format to "Xml".
Next, drag a Query XML action to the pearl after the Call Web Service action. Click on Insert Reference, and select your Workflow variable (from the previous step). In "Process using" select XSLT and in the lower text box, add the following XSL :
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:template match="/" xmlns:n="http://schemas.microsoft.com/sharepoint/soap/">
<xsl:value-of select="count(//n:Attachments/n:Attachment)"/>
</xsl:template>
</xsl:stylesheet>
The result is a numeric value but is returned as text, and therefore requires you to store it in a Workflow Variable of type text.
I have attached a simple Workflow to this thread incase it might come in handy for someone.