1

validation

select jiraaccount,displayname from mcigeneralname where jiraaccount = ?

search sql

select jiraaccount,displayname from mcigeneralname
where lower(jiraaccount) like lower(?) || '%' 

configuration script :

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.customfields.option.Option
import com.onresolve.scriptrunner.canned.jira.fields.editable.database.SqlWithParameters
import com.atlassian.jira.component.ComponentAccessor;


def userinfousername = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getUsername()
String userinfo = userinfousername


getSearchSql = { String inputValue, Issue issue, String originalValue ->

new SqlWithParameters(
"select jiraaccount,displayname from mcigeneralname where jiraaccount like ? || '%' and jiraaccount = ?",
[inputValue,userinfo]
)
}

getValidationSql = { String id, Issue issue,String originalValue ->

new SqlWithParameters("""
select jiraaccount,displayname from mcigeneralname
where displayname = ? and jiraaccount = ?
"""
, [id, userinfo])
}

when userinfo variable set to a string it works but when the current user is passed to the script it's not working

for example userinfo = 'm.moeini'

How can i pass currentuser t configuration script?

1 Answers1

0

My first recommendation is to not access directly to the database, as could lead into different errors and also in a DC instance with different nodes, the information obtained couldn't be always 100% true.

Yunnosch
  • 26,130
  • 9
  • 42
  • 54
  • 1
    Please don't use answers to ask for more information. Once you earn enough reputation, you will be able to leave comments. The "Post Your Answer" button should only be used for content which actually attempts to answer the question at the top of this page. – tripleee Aug 28 '23 at 07:34
  • I edited this into an answer. You might however find that it will be more appreciated if you also [edit] and make it more obviously according to [answer]. Even after I deleted the question from it, this still gives a little of an impression of a comment - for which you would have needed the commenting privilege (see https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead ). – Yunnosch Aug 28 '23 at 08:43
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/34908646) – dcolazin Aug 31 '23 at 20:54