# Code stop working after last Salesforce Exalate Upgrade

**URL:** <https://community.exalate.com/t/code-stop-working-after-last-salesforce-exalate-upgrade/5368>\
**Category:** General Questions\
**Tags:** cloud-salesforce, scripting, migrated\_question\
**Created:** [November 4, 2024, 8:00am UTC](https://community.exalate.com/t/code-stop-working-after-last-salesforce-exalate-upgrade/5368 "2024-11-04T08:00:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)\
**Post date:** [November 4, 2024, 8:00am UTC](https://community.exalate.com/t/code-stop-working-after-last-salesforce-exalate-upgrade/5368/1 "2024-11-04T08:00:27Z")

</div>

_Originally asked by Andrea Mura on 30 November 2022 [(original question)](https://oldcommunity.exalate.com/questions/58497323)_

* * *

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](http://entity.id)}", "body":{ "messageSegments":\[{"type":"Text", "text":"${comment.body}"}] }, "feedElementType":"FeedItem", "visibility":"AllUsers"}""",  
    groovy.json.JsonOutput.toJson(\["subjectId":[entity.id](http://entity.id),"body":\["messageSegments":\[\["type":"Text","text":comment.body]]],  
    "feedElementType":"FeedItem", "visibility":visibility]),  
    null,   
    \["Content\-Type":\["application/json"]])  
    {  
        req, res2\-\>[res2\.body.id](http://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?

* * *

#### Comments:

> **Serhiy Onyshchenko commented on 30 November 2022**
>
> > Hello, Andrea Mura
> 
> Might I ask you to try replacing
> 
> ```auto
> store(entity)
> 
> ```
> 
> with
> 
> ```auto
> if (firstSync) {
> binding.variables.put("connection", nodeHelper.connection)
> store(entity)
> }
> 
> ```
> 
> And let me know if this helped?  
> Regards, Serhiy.

> **Andrea Mura commented on 05 December 2022**
>
> > 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

---

<div class="post-metadata">

**Author:** ![Majid](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/majid/32/343_2.png) [@Majid](https://community.exalate.com/u/Majid)\
**Post date:** [December 4, 2024, 5:58am UTC](https://community.exalate.com/t/code-stop-working-after-last-salesforce-exalate-upgrade/5368/2 "2024-12-04T05:58:20Z")

</div>


