Scripted Custom Field & Sql Server

SMAtlassianMber
Contributor
April 1, 2019

Hello - I have created a new ScriptRunner Custom Field called "Portfolio Team" to capture the value of the "Team" field which came with Portfolio for Jira. The problem I am having is related to the following query. I get no results.  This field works fine in JQL. 

SELECT distinct dbo.customfieldvalue.ISSUE,dbo.customfield.cfname,
CASE When customvalue is not null then cast(customvalue as varchar)
When NUMBERVALUE is not null then cast(NUMBERVALUE as varchar)
When TEXTVALUE is not null then cast(TextValue as varchar)
When DATEVALUE is not null then cast(DATEVALUE as varchar)
When STRINGVALUE is not null then cast(StringValue as varchar)
End as CustomValueFinal
FROM dbo.customfieldoption RIGHT OUTER JOIN
dbo.customfieldvalue ON dbo.customfieldoption.ID = try_cast(dbo.customfieldvalue.STRINGVALUE as numeric) RIGHT OUTER JOIN
dbo.customfield ON dbo.customfieldvalue.CUSTOMFIELD = dbo.customfield.ID
where cfname like '%Portfolio Team%'

 

Field Name: Portfolio Team

Searcher: Free Text Searcher

Template: Text Field (multi-line)

import com.atlassian.jira.component.ComponentAccessor

def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()

def teamPortfolio = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_11900")
def teamValue = issue.getCustomFieldValue(teamPortfolio)

if (teamValue) {
return teamValue.getDescription().getTitle()
}

return null

1 answer

0 votes
Joanna Choules
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.
April 4, 2019

Hi,

The values of Scripted Fields are not stored in the database: they are calculated dynamically when they are accessed via Jira. Hopefully this helps explain the behaviour you're seeing.

Yours,

Joanna Choules, Adaptavist Product Support

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events