How do i get Collecting customer satisfaction (CSAT) feedback data using script runner

GopiR October 26, 2017

How do i get Collecting customer satisfaction (CSAT) feedback data using script runner.

I need to get the values of rating, comment and received date of issue so that i will copy them in different custom fields

Following is the reference link which i am talking about

https://confluence.atlassian.com/servicedeskserver036/collecting-customer-satisfaction-csat-feedback-921471876.html

1 answer

2 votes
Thanos Batagiannis _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 10, 2017

Hi Gopi,

So the satisfaction and the satisfaction date are custom fields therefore you can get their values in the same way you do with any other custom field. So for example the following 

def issue = ComponentAccessor.issueManager.getIssueByCurrentKey("TSD-1")
def satisfactionCF = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Satisfaction")
def satisfactionDateCF = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Satisfaction date")

def satisfaction = issue.getCustomFieldValue(satisfactionCF)
def satisfactionDate = issue.getCustomFieldValue(satisfactionDateCF) // this is a timestamp

log.debug "satisfaction rate for issue ${issue.key} is ${satisfaction?.rate} stars out of ${satisfaction?.scale} and date entered is $satisfactionDate"

will create a log entry 

satisfaction rate for issue TSD-1 is 3 stars out of 5 and date entered is 2017-11-10 17:58:20.018

I am not sure how you can get the comment yet, but I will try a couple of things and will let you know. 

Regards, Thanos

Simonas Jutkevičius April 4, 2018

Hi, you can get the feedback comment this way:

import com.atlassian.jira.bc.issue.properties.IssuePropertyService
import com.atlassian.jira.component.ComponentAccessor
import groovy.json.JsonSlurper

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

def issueManager = ComponentAccessor.getIssueManager()
def issue = issueManager.getIssueObject("TSD-1")

def issuePropertyService = ComponentAccessor.getComponent(IssuePropertyService)
def satisfactionCommentProperty = issuePropertyService.getProperty(user, issue.getId(), "service-request-feedback-comment").getEntityProperty().getOrNull()

if (satisfactionCommentProperty)
{
    def satisfactionComment = new JsonSlurper().parseText(satisfactionCommentProperty.getValue()).comment
    log.warn(satisfactionComment)
}

The only problem we face is that when it is used in listener, it returns the previous (not updated, usually empty) value of comment.

Simonas Jutkevičius April 4, 2018

Also you can select if trom DB:

select `ENTITY_ID`, `json_value` from `entity_property` where `PROPERTY_KEY` = 'service-request-feedback-comment';

Where  ENTITY_ID is issue ID.

Steven Mustari
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 30, 2019

This was working great in 7.X but in 8.5.1 (possibly since 8.0).

The script is pulling any new satisfaction data since the upgrade but will not return any older data.

Any advice on how to get this pulling both new and comments from before the upgrade?

Regards,

Steven

Suggest an answer

Log in or Sign up to answer