I have a custom field with 4 values. I want to set up a post function at the create transition, which automatically updates the Epic links when a story is createdm based off the value selected for the custom field.
Also, these are 4 epic key, which will never be closed. so it ll be a on going process.
Can someone please help me with the Bob Swift CLI command for establishing this. Thank you
@Antoine Berry @[deleted]
Hi Antine ,
I have a request to update EPIC (End date) , Depending on the completion date of the last story in the Epic.
Any post functions that could achieve this (or ) any script functions available.
Hi @siva , I would suggest you open a new question you will have much more visibility.
Antoine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@[deleted]
Could you have a look at the new query i have created.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Aisha M ,
Could you please thoroughly explain your need ? How many custom fields do you have, what types, what issue types and what do you want to achieve ?
Also, I do not own Bob Swift CLI at the moment so would ScriptRunner be an option ?
Antoine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Antoine Berry Just in case you are interested :)
Yes ! scriptrunner would be great too . . I think we need to add the script at the create step of the Project workflow.
Below is the scenario.
We have a Service Desk project, where they want to automatically populate EPIC LINK values based on a CUSTOM FIELD VALUE selected during the ticket creation phase.
Basically, automate the population of “Epic Link” from the value selected in the “Work Request Type” field
Work Request Type = Epic Link
Also, these epic links are constant, wont keep changing :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If I understood well, Work Request Type is a select list (Single value) ?
Also, are you using Epics in a service desk project ? Seems more like a software project right ?
Antoine
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 the comment !
Yes, its a select list (Single Value) field. And the field has just those 4 values. And the Epic links are constant too
Sorry, yes, its a software project.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Aisha M ,
Please find the script below. I have added a Map so that you can change/add/remove values easily if need be (remember that the select list values and the epic keys must match perfectly). With the current behaviour, if the user picks "Other", or nothing at all, the epic link is not updated. That can be modified if you want.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
import org.apache.log4j.Logger
import org.apache.log4j.Level
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def epics = ["Common Layer Merge Request": "PEAGACOE-13",
"Design Review": "PEGACOE-30",
"Pega Research": "PEGACOE-20"]
def workRequestTypeId = 11004
def workRequestType = customFieldManager.getCustomFieldObject(workRequestTypeId)
def workRequestTypeValue = issue.getCustomFieldValue(workRequestType)
def epicLinkId = 10101
def epicLink = customFieldManager.getCustomFieldObject(epicLinkId)
def epicLinkValue = issue.getCustomFieldValue(epicLink)
def epicToSet = issueManager.getIssueObject(epics[workRequestTypeValue?.getValue()])
if (epicToSet){
epicLink.updateValue(null, issue, new ModifiedValue(epicLinkValue, epicToSet), new DefaultIssueChangeHolder())
}
Antoine
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.
@Antoine Berry Thank you for taking the time to work this out :) Really appreciate it . . I was out of work for some days , so couldn't test it out. Planning to try your script now *fingers crossed* :D
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@
Hi Antoinie @Antoine Berry It did not work unfortunately :( Maybe I m doing it wrong . .
The field is in service desk, so do I need to do something different ? Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Aisha M ,
You mean on the servicedesk portal ? It seems like a software project since you have epics. Also, could you please provide the logs (otherwise it is hard to debug from there) ?
I remember testing this and it worked fine, so we should find a way.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Antoine Berry Hi :)
Actually, the Epics are in a different project. And the fields are in a service desk project.
Maybe I ll try this out in a new project, with the Epics in the same project, to see how it works.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Make sure the behaviour triggers correctly on the current projet first, by adding a log line in the code. Then check for errors :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Aisha M Makes me wonder, did you make this work ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Aisha M,
Yes, you can use the "CLI action"post function from "Run CLI actions fo JIRA" to implement this functionality. Make sure to place the post functions below the native "Re-index an issue to keep indexes in sync with the database." post function in the story workflow. See the example below for reference :
You may need to put 4 post functions for each value in the field.
Thanks,
Swathi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@[deleted] Thank you so much Swathi.
So from the sample you had shared , 'RC-1' is the epic link ID is it ? Also, where do I specify the custom field value for the corresponding Epic Link ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Aisha M,
Yes, RC-1 is the EPIC issue key.
For adding custom fields, you can use --custom parameter. See the sample action which updates two custom fields namely "isExternal" and "RandomField".
--action updateIssue --issue "%original_key%" --server %base_url% --user admin --password admin --field "Epic Link" --value "RC-1" --custom "isExternal:Yes,RandomField:abh"
Thanks,
Swathi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@[deleted]
As an example, I m trying this scenario with a custom field that has two values - Text 1 ; and Text 2.
If issue created with field value, "Text 1" , the epic ID should be STP-824
If issue created with field value, "Text 2", the epic ID should be STP-825
Can you please help with framing the action for this scenario please. I have been struggling with this for so long.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Aisha M,
For validating the value of the custom field, you can use "Condition" section at the top in the post function. See the screenshot below :
Hope you are using RUN CLI actions for JIRA and not JIRA command line interface.
Thanks,
Swathi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@[deleted] Really appreciate you helping :)
Well, unfortunately does not work :(
I tried adding a post function at the create transition (so that once an issue is created, the issue is automatically undated with the epic link based on the field value)
Condition 1 - %original_customfield_14100% Pattern - Text1
Action - -a run --server %base_url% --options basicAuthentication --user "Automation" --password "****"
Data - --action updateIssue --issue "%original_key%" --field "Epic Link" --value "STP-824"
Any idea why it ain't working ? Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Aisha M,
Your post function seems to be correct. However, I suspect that you might have placed the post function in the first place (in create transition). Can you confirm if the order is in the correct place? Make sure to place it after the "Re-index an issue to keep indexes in sync with the database." post function.
If you still see any issues, please raise a support request here so we can take a look at the debug logs.
Thanks,
Swathi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@[deleted] Hi Swathi,
I have placed it below the "Re-index an issue to keep indexes in sync with the database." post function".
Any other reason it could be failing ?
Thank you
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.