Ricardo Simmus
Ricardo Simmus

Reputation: 334

Get custom field value in web-item(velocity) context

Basically I'm trying to predefine some values with URL by creating a web-item with link to CreateIssueDetails!init.jspa operation:

<web-item key="has-defect" name="has-defect" section="operations-operations">
        <label>Has Defect</label>
        <link linkId="issueaction-has-defect">/secure/CreateIssueDetails!init.jspa?ppid=$issue.id&amp;pid=$issue.project.id&amp;issuetype=27&amp;lname=Defect&amp;customfield_10056=$issue.getCustomField("customfield_10056").name&amp;assignee=$issue.assignee.name&amp;customfield_10011=$issue.getCustomFieldValue("customfield_10011")&amp;customfield_10046=10248&amp;customfield_10022=$issue.getCustomFieldValue("customfield_10022")</link>
</web-item>

Assume I have an Issue with custom field "Some Custom Fied" value in it, is it possible get it's value from issue like I'm getting for example Assignee: $issue.assignee.

I've already tried :

$issue.getCustomField("customfield_10056").value;
$issue.getCustomField("customfield_10056").name;
$issue.getCustomFieldValue("customfield_10056")

Thanks for your time.

Upvotes: 0

Views: 2564

Answers (3)

Jaanus
Jaanus

Reputation: 16541

You should extend AbstractJiraContextProvider.

Example here:

https://bitbucket.org/atlassian/tutorial-jira-add-content-to-view-issue-screen/src/58aca50e970125b34fb70bde1edac9a29cb67a9e/src/main/java/com/example/plugins/tutorial/DueDateIndicator.java

And inside you web-item you can use the context-provider:

  <context-provider class="com.example.plugins.tutorial.DueDateIndicator"/>

Upvotes: 0

user2919302
user2919302

Reputation: 1

You have to do this in 2 steps:

#set($customFieldObj = $customFieldManager.getCustomFieldObject("customfield_10056"))

"customfield_10056" is the field identifier.

And then:

$cutomFieldObj.getValue($issue))

It must work.

Upvotes: 0

mdoar
mdoar

Reputation: 6881

A web-item is defined in an atlassian-plugin.xml file, but you're expecting it to behave like a Velocity template file. I don't think that $issue will be expanded as you want, or is it?

Upvotes: 0

Related Questions