I have a project with two issuetype:
a) activate account
and
b) deactivate account
I use the first issue type to create an account activation request, which is approved. when it is approved I store the value "active" in a customfield called "status account"
when a user of jira wants to deactivate an account, I first do a search to see if I already have the account activated. So I use issue type b) and through a customfield script and a JQL I find all the issue types a) that are with status = approved and customfield status account = active and show them in the list.
then the user chooses only one value from this list. this value corresponds to the issue type a) which is the initial activation request.
I would like to ensure that when the issue type b) (deactivation of accounts) is approved, the custom field "status account" of the issue type a) is updated, which I have selected before, with a new value = inactive. but i do not know how you do this with postfunction and script runner, can anyone help me?
Why don't you use just a single issue type and do the status via workflow?
You do not have to do the updates of other issues then and have all information in one place?
Meanwhile, thank you for your reply. Simple, because I had not thought about it and because I'm now starting to practice so I do not know how to set this configuration that you suggest and I do not want to take advantage of the patience of those like you who is helping me.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are welcome.
The easiest way to set that up is to simply add the workflow of account deactivation issue type to your other workflow.
You might need to think if there is some status needed for the transition of one workflow to the other, but in general that is what I meant.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
well, thank you for your suggestion
I have already created two workflows, WFA which is linked to the issuetype Active Account and WFB which is connected to the issuetype Deactive Account
so when an account activation request is made, I use WFA and Active Account
when I have to deactivate an account, I propose the issuetype Deactive Account and the WFB.
the problem that I still can not solve and that maybe I have not explained well before is that I have to check before disabling an account, if this account exists already activated
then in WFB, that of disabling account to understand, I use a scripted custom field and scriptrunner that calls a JQL that finds all the issues of type Active Account that have the status "actived"
and presents them to the user to allow them to choose which issue = active account, they want to deactivate.
it is at this point that I do not know how I can "take" the issuekey of the issue chosen by the user and pass it to scriptrunner to say: put the issuekey X in status = deactived. In short, I would like to change the status of the "Acrtive Account" issue chosen by "Actived" to "Deactived". I'm continuing to search with google to see if I can find an example.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your explanation.
What I meant waa, that if you let the users select one of the active accounts and they can set that issue just to the first status of the WFB workflow(and you run through this workflow), you have everything in this one issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yes, I'll explain better, I've already done something similar to what you suggest and it came easy because it was jira's account = users. In this second problem, however, where I wrote "account" I mean more exactly "name of an object" as if it were in a CMDB. It would be enough to understand how to pass the issuekey of an "issue" chosen from a drop-down list, as a parameter to indicate the issue where to find the customfield to modify and I would have solved.up to now I am finding many examples where an issue is indicated directly by writing the key in the scriptrunner code and therefore it does not work for what I want to do.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok so your problem is to get the key as value from your scripted field, right?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
right and next to change the status of this issue from "Active" to "Inactive"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you try to get the value of your scripted field like this?
def value = issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("ScrptedFieldName"))
What is result of this?
For loading the other issue, Please have a look here
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi @Bastian Stehmann Thank you for your help, in the end I took a cue from your suggestion and I improved other code that I wrote.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.event.type.EventDispatchOption
def log = Logger.getLogger("com.acme.CreateSubtask")
log.setLevel(Level.DEBUG)
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
def statusfield = customFieldManager.getCustomFieldObjectByName('Account');
def issuekey = issue.getCustomFieldValue(statusfield);
log.debug issuekey
MutableIssue Missue = ComponentAccessor.getIssueManager().getIssueByCurrentKey(''+issuekey)
log.debug Missue.key
CustomField cfStatoAccount = customFieldManager.getCustomFieldObjectByName('Status')
log.debug cfStatoAccount.name
Missue.setCustomFieldValue(cfStatoAccount,'Inattivo')
log.debug Missue.getCustomFieldValue(cfStatoAccount)
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
ComponentAccessor.getIssueManager().updateIssue(user, Missue, EventDispatchOption.ISSUE_UPDATED, false)
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.