1
0
-1

Hallo,


with Serhiy Onyshchenko  we(he) write a chunk of code that permit to generate a comment with drived visibility from salesforce to Jira.



Here’s the code


//COMMENT INTERNAL/EXTERNAL


    store(entity)
   
    replica.addedComments.collect{
        comment->
        def visibility = comment.internal?"InternalUsers":"AllUsers"
               def commentid = httpClient.http(
        "POST",
        "/services/data/v54.0/chatter/feed-elements",
        //"{\"Comments\":\"[${comment.author.displayName}] commented: ${nodeHelper.stripHtml(comment.body)}\"}",
        //"""{"subjectId":"${entity.id}", "body":{ "messageSegments":[{"type":"Text", "text":"${comment.body}"}] }, "feedElementType":"FeedItem", "visibility":"AllUsers"}""",
        groovy.json.JsonOutput.toJson(["subjectId":entity.id,"body":["messageSegments":[["type":"Text","text":comment.body]]],
        "feedElementType":"FeedItem", "visibility":visibility]),
        null, 
        ["Content-Type":["application/json"]])
        {
            req, res2->res2.body.id
        }
        def trace = new com.exalate.basic.domain.BasicNonPersistentTrace()
         .setType(com.exalate.api.domain.twintrace.TraceType.COMMENT)
         .setToSynchronize(true)
         .setLocalId(commentid as String) 
         .setRemoteId(comment.remoteId as String)
         .setAction(com.exalate.api.domain.twintrace.TraceAction.NONE)
        traces.add(trace)            

    }

    return new scala.Tuple2(issueKey, scala.collection.JavaConverters.asScalaBuffer(traces))



It works very well, but after the last exalate update this code generate an error.

Error Detail Message:

java.lang.NullPointerException



How can we fix?

  1. Serhiy Onyshchenko

    Hello, Andrea Mura 

    Might I ask you to try replacing

    store(entity)

    with

    if (firstSync) {
      binding.variables.put("connection", nodeHelper.connection)
      store(entity)
    }

    And let me know if this helped?
    Regards, Serhiy.

  2. Andrea Mura

    Ho Serhiy,


    with this cose it gives me an error

    Error Detail Message:


    No such property: connection for class: services.node.hubobjects.NodeHelper

    I resolve with: move "store(entity)"  in the first sync section

CommentAdd your comment...