Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Wyt is wrong with Issue object which is not recognised ?

serge calderara
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 Champions.
June 19, 2020

Dear all,

I have the following script which is store in a file named SlackUser.groovy

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.comments.CommentManager

import groovy.json.*
import groovyx.net.*
import groovyx.net.http.*
import static groovy.json.JsonOutput.*
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*

class SlackUser{

Issue refIssue

//Field defienition constant to be read from issue
String emailFieldName="Email Address" //10523
String emailField=""
public String emailFieldValue=""
CommentManager commentMgr=ComponentAccessor.getCommentManager()


SlackUser(Issue issue)
 { 

refIssue=issue
def customFieldMgr=ComponentAccessor.getCustomFieldManager()

emailField =customFieldMgr.getCustomFieldObjects().findByName(emailFieldName)
emailFieldValue=refIssue.getCustomFieldValue(emailField) <<< error


 }
}

Then I am calling that script from my Script console as below :

Issue refIssue=ComponentAccessor.getIssueManager().getIssueObject("TSD-2102")

SlackUser slk=new SlackUser(refIssue)

When the SlackUser object is created, I get a wierd error in the BOLD line above saying :

"groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.IssueImpl.getCustomFieldValue() is applicable for argument types: (java.lang.String) values: [Email Address] Possible solutions: getCustomFieldValue(com.atlassian.jira.issue.fields.CustomField), setCustomFieldValue(com.atlassian.jira.issue.fields.CustomField, java.lang.Object) at ServiceRequest.SlackUser.<init>(SlackUser.groovy:53) at Script564.run(Script564.groovy:71)"

 

What is wrong and how to solve that error ?

regards

2 answers

1 accepted

1 vote
Answer accepted
Cyril Egan
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 Champions.
March 26, 2012

Workaround:

  1. Create a shared user account and add it to the group.
  2. Change ownership of the filters to the new shared user account.
  3. Share the account login details with the group members.
  4. Anyone wishing to update the filter or dashboards for the group would login using the shared user account and make the necessary modifications.
0 votes
tousifs
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 Champions.
March 26, 2012

Hi Sarap,

you can use this plugin https://studio.plugins.atlassian.com/wiki/display/JOUT/Filter+List+Plugin.

or the second approach would be.

Find the class where you need to change or apply your business logic.

find all available for the user saved searches (own and shared filters). We have list ofFilters

List<SearchRequest> filters = filtersResult.getResults();
for (SearchRequest filter : filters) {
// filter.getName()
USer user= filter.getOwnerUserName())

List<Group> group=user.getGroups();

{

//logic if log-in user[Remote user] and group contain in [Login user.getGroups] are contained in each other with same permission.

The user belog to group can edit the same filter.

}

the process to change single class in jira is

https://answers.atlassian.com/questions/43414/easy-way-compile-java-files-of-jira.

may be you have to change Class DefaultSearchRequestService or SearchRequestService interface implementation

make changes in search method. it should work.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events