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?
Hi,
You can look into JIRA APIsThe 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.ComponentAccessordef issueManager = ComponentAccessor.getIssueManager()def customFieldManager = ComponentAccessor.getCustomFieldManager()def issueObject = issueManager.getIssueObject("Issue-Key")// Get your Custom Field by its IDdef customFieldObject = customFieldManager.getCustomFieldObject(customFieldID)// Get All custom fields within a issue scopedef 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}
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?
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?
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.ComponentAccessorimport com.atlassian.jira.issue.ModifiedValueimport com.atlassian.jira.issue.util.DefaultIssueChangeHolderdef issueManager = ComponentAccessor.getIssueManager()def customFieldManager = ComponentAccessor.getCustomFieldManager()// Get issueObject by key. def issueObject = issueManager.getIssueObject("Issue-KEY")// Get the CustomField by its IDdef customFieldObject = customFieldManager.getCustomFieldObject(10125)// Get the current value of CustomField def oldValue = customFieldObject.getValue(issueObject)// Create a new value to assign later onString 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.
It looks like you're new here. Sign in or register to get started.