Hello,
i am having trouble setting a Tempo Account field like this:
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.bc.issue.IssueService.CreateValidationResult
import com.atlassian.jira.util.ErrorCollection
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.user.ApplicationUser
IssueService issueService = ComponentAccessor.getIssueService()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
UserManager userManager = ComponentAccessor.getUserManager()
IssueManager issueManager = ComponentAccessor.getIssueManager()
ApplicationUser user = userManager.getUserByKey("aptisAdmin")
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
issueInputParameters.setProjectId(10400L)
issueInputParameters.setDescription("description");
issueInputParameters.setSummary("summary")
issueInputParameters.setIssueTypeId("10001")
issueInputParameters.setReporterId("aptisAdmin")
String tempoValue = "ACCOUNTNAME"
//tempoValue = "3" // accountID did not work either
CustomField tempoAccountField = customFieldManager.getCustomFieldObjectByName("Account")
issueInputParameters.addCustomFieldValue(tempoAccountField.getId(), tempoValue)
CreateValidationResult createValidationResult = issueService.validateCreate(user, issueInputParameters);
if (createValidationResult.isValid())
{
//do stuff here
} else {
log.error 'Create Result not valid'
ErrorCollection errors = createValidationResult.getErrorCollection()
for (String error : errors ) {
log.error error
}
}
addCustomFieldValue expects a String, but i cant find any documentation on how to properly format the string so that the field will be set to a value.
In the system the account field is obligatory, using both the accountId and the account Key i get an invalid CreateValidationResult with the Error:
Error Messages: [Account: Account ist erforderlich.]
(in english Account is required)
thanks in advance
Jens
@Greg Fischer : I worked around the probem by setting a default account on the projects in question.
Supplying a json in the format that a set Account field has in the Jira Rest API doesnt work either
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jens,
Did you ever get this to work? I need to do the exact same thing (create an issue where the Tempo Account field is a required field at create time), but from a workflow post-transition Groovy script. I have tried getting all the valid Account objects using Loic's solution here: https://community.atlassian.com/t5/Marketplace-Apps-Integrations/Tempo-Java-API-documentation/qaq-p/886471
but I keep getting a java.lang.NoClassDefFoundError: com/tempoplugin/accounts/account/api/AccountService when it runs. The ScriptRunner Groovy editor gives me a green light so it doesn't find anything wrong.
Thanks,
-Greg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Never mind. I did get this to work by using the Account ID, so
CustomField account = customFieldManager.getCustomFieldObjectByName("Account")
IssueInputParameters reqIssueInputParameters = issueService.newIssueInputParameters();
reqIssueInputParameters.addCustomFieldValue(account.getIdAsLong(), accountID)
where the accountID variable is a String.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.