1

I'm trying to send attachment file from youtrack to another system (in this example to trello) without the use of image url but its content

I cannot send it as image url in youtrack because my system is closed and accessible to only those that have vpn.

Problem is with reading inputStream from content of attachement in workflow. I symply have no idea how to do it and youtrack documentation havent touched it (as far as my research goes)

Code: (with truncated not important parts)

//...

exports.rule = entities.Issue.onChange({
  //...
  action: function(ctx) {
    //...
    var link = '/1/cards/' + issue['trelloIssueId'] + '/attachments';

    issue.comments.added.forEach(function(comment) {
      comment.attachments.forEach(function(attachment) {        
        var response = connection.postSync(link, {
          name: attachment.name,
          file: attachment.content,
          mimeType: attachment.mimeType
        });

        //...
      });
    });
  },
  requirements: {}
});

from this I got error:

TypeError: invokeMember (forEach) on jetbrains.youtrack.workflow.sandbox.InputStreamWrapper@677a561f failed due to: Unknown identifier: forEach

How do I have to prepare content to ba abble to send it with postSync method?

ciekals11
  • 2,032
  • 1
  • 10
  • 24

1 Answers1

0

It looks like you tried to iterate over issue.comments.added while the loop should be executed over issue.comments as there is no added key for an issue's comments Set as per the following documentation page suggest: https://www.jetbrains.com/help/youtrack/devportal/v1-Issue.html

Please let me know if that works.

skoch13
  • 94
  • 4
  • Um. That is not my problem here. I'm iterating over comment and I can get their content. I'm interested in only added comment so I dont send attachment more than once. My problem is in sending attachment file content via http because I don't know how to prepare InputStream in javascript – ciekals11 Apr 20 '21 at 15:14
  • Please accept my apologies for the confusion. Could you please clarify if you try to iterate over all of the existing comments of the issue or only that are added during the current workflow rule execution? – skoch13 Apr 21 '21 at 16:00
  • Only that that are added. I have just got un update that [this issue](https://youtrack.jetbrains.com/issue/JT-59500) has been resolved. I just have to wait for release and it will kinda solve my problem – ciekals11 Apr 21 '21 at 19:21
  • But If you have other solution I will be happy to hear it. – ciekals11 Apr 22 '21 at 11:21
  • If the error mentioned initially is not the case anymore we have to wait until the said feature will be released with one of the next releases – skoch13 May 05 '21 at 15:55