Hi,
I try to set users to a field related to another field. Please see my coding. But it seems not to work at all.
It is a custom post-script function
/** * Created by guenterm on 11.02.2015. */ import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.MutableIssue MutableIssue curIssue = issue // Field-Value is related for copied value (Type: InTENSO [Dynamic Forms] - Dynamic Select) def condField = "customfield_11091" // Target-Field (Userfield - multiple) def target = "customfield_11100" // Get condFields value def cfManager = ComponentAccessor.getCustomFieldManager() def cfCond = cfManager.getCustomFieldObject(condField) def selectedVal = cfCond.getValueFromIssue(curIssue) // Related on value set targets field value def cfTarget = cfManager.getCustomFieldObject(target) // Now copy the value into target if (selectedVal == "Cat") { curIssue.setCustomFieldValue(cfTarget, "user-x") } else if (selectedVal == "Dog") { curIssue.setCustomFieldValue(cfTarget, "user-y,user-z") }
Have you any ideas why it is not working? No error in atlassian-jira.log
Best Regards, Mario
Community moderators have prevented the ability to post new answers.
Try something like this.
cfTarget.updateValue(null, curIssue , new ModifiedValue(curIssue .getCustomFieldValue(cfTarget), "user-x"), new DefaultIssueChangeHolder());
Also you can try using API that i mensioned here
Hi Andrey, it seems not to work, I'll try to follow the API snippet and report back soon - Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, I tried the APIs Doc. And this Snippet is not working, too -.- {code} import com.atlassian.jira.ComponentManager import com.atlassian.jira.bc.issue.IssueService import com.atlassian.jira.issue.IssueInputParameters /** * Created by guenterm on 11.02.2015. */ IssueService issueService = ComponentManager.getIssueService(); IssueInputParameters issueInputParameters = issueService.newIssueInputParameters(); //Prio setzen: issueInputParameters.setPriorityId() issueInputParameters.addCustomFieldValue(11100L, "user-x"); {/code} I'm running on Jira version 6.3.5
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Mario. You forgot to add code from example UpdateValidationResult updateValidationResult = issueService.validateUpdate(user, issueId, issueInputParameters); if (updateValidationResult.isValid()) { IssueResult updateResult = issueService.update(user, updateValidationResult); if (!updateResult.isValid()) { // Do something } }
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.
I have a question here:
When setting a value for a custom-field, why we should give "user-x" - something like that? should we give current user name? if so, will the script work for other users?
I am trying copy one custom field's value to another customer field which is of type "single drop-down list".
thanks,
Khadhar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you ask a new question with a bit more detail? This is 2+ years old.
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.
Hi Jamie,
I have a similar issue:
I need to set the date in a custom field based on due date and Custom field value(Yearly, Monthly etc.)
You can find my Question
Please advice.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For future reference, rather than saying "it doesn't work at all", can you explain what you expect to happen and what is actually happening, even if that's "nothing".
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.