Hi Andreas!
We are struggling using the calc. metadata field for project wide information which we want to copy into a customfield on the "CREATE" trigger in our workflow.
background: we have a metadata variable "crmid" which we want to copy to a certain customfield on creation of the ticket (but only if this customfield was not set by our helpdesk team).
I created a calc. metadata customfield (helper.crmid) which is:
#set( $tcrmid = $metadataService.getMetadataValue($issue.projectObject, 'crmid') ) $tcrmid
and when I display it on the default screen it works and display the respective crmid which is set of the issue's project.
But when we create a post function on "Create" in our workflow and copy the value from field helper.crmid to certain customfield, we end up with the exact code of the helperfield in our customfield (see above) and not the awaited calculated result (e.g.=2).
How can we get this working?
No unfortunately not - I use nearly the same order (except further copies of different fields), but i always get the sourcecode of the metadata field in my custom field after creation. here is a screenshot of my postfunctions. Is there anything wrong?
A different try: AS you meantioned to use groovy instead, there is a post function "set customfield based on groovy expression".
When I use this groovy expression for my customfield crmid:
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.comments.CommentManager
import com.opensymphony.workflow.WorkflowContext
import com.atlassian.plugin.osgi.container.OsgiContainerManager
import org.apache.log4j.Category
OsgiContainerManager osgiManager = ComponentManager.getInstance().getComponentInstanceOfType(OsgiContainerManager.class)
return osgiManager.getServiceTracker("com.osoboo.jira.metadata.MetadataService").getService().getMetadataValue(issue.getProjectObject(), "crmid")
it still doesnt work - do you know why?
the above example was an example of yourself, but it doesn't work - it seems as "import com.atlassian.plugin.osgi.container.OsgiContainerManager" cannot be resolved - do you have a solution for me ... I just need any solution to get the metadata of the project during the creation post function and to set a certain customfield with that static value.
Big Thanks in advance.
hi
try the following
that's working! BRILLIANT THANKS VERY MUCH!!!