Skip to Content

Converting attachments into text

  • Origin: Calculated attribute

In order to convert attachments into text attribute (for example, to get the list of names of these attachments, or to have clickable links to them), enter the following expression:

Attachments from current item only (subtasks attachments not included):

  • Link:
@prefix cmw: <http://comindware.com/logics#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix string: <http://www.w3.org/2000/10/swap/string#>.
@prefix attachment: <http://comindware.com/ontology/attachment#>.
@prefix configuration: <http://comindware.com/ontology/configuration#>.
@prefix assert: <http://comindware.com/logics/assert#>.
{
  {
    configuration:ActiveConfiguration configuration:baseUri ?url.
  } assert:range (0 1).
  ?item cmw:attachment ?attach.
  ?attach attachment:actualRevision ?rev.
  ?rev attachment:httpUri ?revUrl.
  (?url ?revUrl) string:concatenation ?value.
}
  • Filename
@prefix cmw: <http://comindware.com/logics#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix string: <http://www.w3.org/2000/10/swap/string#>.
@prefix attachment: <http://comindware.com/ontology/attachment#>.
@prefix configuration: <http://comindware.com/ontology/configuration#>.
@prefix assert: <http://comindware.com/logics/assert#>.
{
  {
    configuration:ActiveConfiguration configuration:baseUri ?url.
  } assert:range (0 1).
  ?item cmw:attachment ?attach.
  ?attach attachment:actualRevision ?rev.
  ?rev attachment:fileName ?value.
}
  • Filename as link
@prefix cmw: <http://comindware.com/logics#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix string: <http://www.w3.org/2000/10/swap/string#>.
@prefix cmwstring: <http://comindware.com/logics/string#>.
@prefix attachment: <http://comindware.com/ontology/attachment#>.
@prefix configuration: <http://comindware.com/ontology/configuration#>.
@prefix assert: <http://comindware.com/logics/assert#>.
{
  {
    configuration:ActiveConfiguration configuration:baseUri ?url.
  } assert:range (0 1).
  ?item cmw:attachment ?attach.
  ?attach attachment:actualRevision ?rev.
  ?rev attachment:fileName ?fileName.
  ?rev attachment:httpUri ?revUrl.
  (?url ?revUrl) string:concatenation ?fileUrl.
  ("<a href='{0}'>{1}</a>" ?fileUrl ?fileName) string:format ?value.
}

 

Attachments from subtasks:

To convert attachments from subtasks to text, simply substitute item cmw:attachment ?attach. with: ?item attachment:attachmentsTreeWithChildren ?attach. in the respective expression above.

If you want to include both attachments from item and subtasks, use assert function when writing an expression.