1
0
-1

Hi,


I'm trying to sync comments so when the author is present in both system then we do not need to have the sync user info showing by using  the below

/*

Sync comments with the original author if the user exists in the local instance
Remove original Comments sync line if you are using this approach
*/
issue.comments = commentHelper.mergeComments(issue, replica){ it.executor = nodeHelper.getUserByEmail(it.author?.email) }


But if the user is not present in the remote system then use 

issue.comments = commentHelper.mergeComments(issue, replica)


Is there a way to accomplish this?


Thanks,


Ziad

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hi, I have an example here that should help you We have integrated ZD with SN but when we push Tickets to Zendesk it is losing people date like Requester/Agent and replacing it with my information in the ZD ticket.


      The idea is that you only add the User prefix if it's now found:


      issue.comments = commentHelper.mergeComments(issue, replica){ comment ->
        comment.executor = nodeHelper.getUserByEmail(comment.author?.email)
        if(comment.executor == null){
           comment.body = "Comment from servicenow by "+comment.author?.username + "\n:" + comment.body
        }
      }


      Hope it's helpful.


      Juan

      1. Ziad Qadora

        Hi Juan,


        I get the same error when use the provided error as the one when using the code below


        issue.comments = commentHelper.mergeComments(issue, replica){ it.executor = nodeHelper.getUserByEmail(it.author?.email) }


        Below is the error


        com.exalate.api.exception.script.CreateProcessorException: Script error details: Comment could not be created because FORBIDDEN.<Username>, you do not have the permission to comment on this issue.. Error line: IssueLinks.groovy:774 at com.exalate.error.services.ScriptExceptionCategoryService$.wrapAsCreateProcessorException(ScriptExceptionCategoryService.scala:54) at com.exalate.processor.jira.JiraCreateIssueProcessor.createIssue(JiraCreateIssueProcessor.java:162) at com.exalate.replication.request.CreateIssueSyncRequestState.transition(CreateIssueSyncRequestState.java:73) at com.exalate.replication.request.CreateIssueSyncRequestState.transition(CreateIssueSyncRequestState.java:24) at



        Regards,


        Ziad

      2. Juan Grases

        That means that the user set on the executor doesn't have permission to create comments on that issue. We have seen that Jira API blocks customers to create comments for example. Was the user a customer?

      3. Ziad Qadora

        Hi, 


        The users in this case are vendors who have no access to the remote system.  I'm just trying to see if there is way to resolve the issue on hand.


        Regards,


        Ziad

      4. Ziad Qadora

        Hi,


        Correct, but in this case they are vendors who do not have to the remote system.



        Regards,


        Ziad

      5. Ziad Qadora

        For what I'm trying to do the user need to exist in the local instance

      6. Francis Martens (Exalate)

        Ziad Qadora

        What is the current status.  Is Juan's suggestion helping?

      7. Ziad Qadora

        I reverted to the default comment sync because the users have to be on both sides in order to use the solution that Juan suggested.

      8. Francis Martens (Exalate)

        OK - got it.
        In the cases where the creation failed because the executor was a customer - are you sure that the customer request type was set on the ticket?

      CommentAdd your comment...