I added custom field on Jira server and I want to update that field using Atlassian SDK (.Net), I can not able to do this with right approach.
Could you please help me?
You are going to need to explain what context your code is running in.
Is it an add-on for Server, and add-on for Cloud, an external program, or are you hacking the core of Jira?
Hi,
You can look into JIRA APIs
The main one you can look into is ComponentAccessor. From here you can explore more methods that better suit your needs.
For example if you want to find something related to issue and customfields, then you can look into their APIs and methods.
From ComponentAccessor you can navigate IssueManager Api and CustomFieldManager and explore them for your particular usage.
There are certain plugins as well like ScriptRunner that can help you add back-end code to a field and update it.
For example you can access your custom field from a certain issue like this:
import com.atlassian.jira.component.ComponentAccessor
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueObject = issueManager.getIssueObject("Issue-Key")
// Get your Custom Field by its ID
def customFieldObject = customFieldManager.getCustomFieldObject(customFieldID)
// Get All custom fields within a issue scope
def customFieldObjects = customFieldManager.getCustomFieldObjects(issueObject)
// See if your customfield is in the issue
// If it is, then do what you want with it.
if (customFieldObjects.contains(customFieldObject))
{
// Do your stuff with the field
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for reply.
Actually I'm using Atlassian.SDK which supports for .Net Library.
I am able to fetch custom fields but stuck to update that field through code.
For example :
var temp = await JiraInstance.Fields.GetCustomFieldsAsync();
using this I can retrieve all custom fields for that project but how can i updated particular fields?
Could you please help me?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To update the customField you can use the updateValue method.
It takes in Fieldlayout, IssueObject, Modified Value (need to pass both old and new value) and IssueChagneHolder.
You can try something as follows:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
// Get issueObject by key.
def issueObject = issueManager.getIssueObject("Issue-KEY")
// Get the CustomField by its ID
def customFieldObject = customFieldManager.getCustomFieldObject(10125)
// Get the current value of CustomField
def oldValue = customFieldObject.getValue(issueObject)
// Create a new value to assign later on
String newValue = "New Value"
//Main method to update custom field.
changeHolder = new DefaultIssueChangeHolder()
customFieldObject.updateValue(null, issueObject, new ModifiedValue( oldValue, newValue), changeHolder)
As an example I was explicitly getting issue object based on key, you can change that to generalize it for all issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.