Questions for Confluence license has expired.

Please purchase a new license to continue using Questions for Confluence.

How to sync attachment from the request on service now to jira

 
1
0
-1

I need to send attachment from service now to Jira but the files attach to the request and not to the catalog task.

I tried to use:     replica.attachments    = catalogTask.attachments, but it sync files that attach to the catalog task.

How can I sync it?

    CommentAdd your comment...

    4 answers

    1.  
      1
      0
      -1

      Hi Yael ,


      I have been able to reproduce your issue.


      Please try the following:


      Incoming SNOW instance:

      if(entity.tableName == "incident") {
          replica.key            = entity.key
          replica.summary        = entity.short_description
          replica.description    = entity.description
          replica.attachments    = entity.attachments
          replica.comments       = entity.comments
          replica.state          = entity.state
          
          /*
          Use a field"s internal name to send its value
          Example: Resolution Notes -> resolution_notes
          This works for all other entity types as well
          
          replica.resolution_notes = entity.resolution_notes
          */
      }
      //any other entity can be synced using the table name and the entity variable
      else if(entity.tableName == "cmdb_ci_business_app") {
          replica.key            = entity.key
          replica.summary        = entity.short_description
          replica.description    = entity.description
          replica.name           = entity.name
      }
      else if(entity.tableName == "sc_task") {
          replica.key            = entity.key
          replica.summary        = entity.short_description
          replica.description    = entity.description
          if (entity.request_item) {
              def await = { f -> scala.concurrent.Await$.MODULE$.result(f, scala.concurrent.duration.Duration$.MODULE$.Inf()) }
              
              def orNull = { opt -> opt.isDefined() ? opt.get() : null }
              
              def ritmId = entity.request_item.link.split("/").last()
              
              def attachments = nodeHelper.snowClient.getAttachmentsMetadata(ritmId)
              
              def sequenceOfAttachments = await(attachments)
              
              def listOfAttachmentsResults = scala.collection.JavaConverters.seqAsJavaList(sequenceOfAttachments)
              
              def listOfHubAttachments = listOfAttachmentsResults.collect({
                  attachmentResult ->
                  def a = new com.exalate.basic.domain.hubobject.v1.BasicHubAttachment()
                  a.filesize = attachmentResult.size_bytes as long
                  a.id = attachmentResult.sys_id as String
                  a.filename = attachmentResult.file_name as String
                  a.mimetype = attachmentResult.content_type as String   
                  a
      
              })
              
              replica.attachments = listOfHubAttachments
          }
      }



      1. Yael

        Hi,

        It's work.

        Thanks a lot  (smile)(smile)

      CommentAdd your comment...
    2.  
      1
      0
      -1

      Hi Yael ,


      I have been able to set up the scenario and I am still working in order to reproduce the issue. 


      I will provide an update as soon as I can Exalate the attachments or next Friday (24th February).

        CommentAdd your comment...
      1.  
        1
        0
        -1

        Hi Yael,

        I am still working on this issue and try to update this thread by the end of the week.


        Kind regards,


        Andres

          CommentAdd your comment...
        1.  
          1
          0
          -1

          Have you tried:

          replica.attachments    = issue.attachments

          Kind regards,

          Ariel

            CommentAdd your comment...