Hi everyone, I wrote a script that changes the follow up date to from what it is to the next follow up date when a comment is added.
I am getting this error:
Variable "event" masks a binding variable of the same name. Please choose a different name for variable: "event"
Hi @Anele
Welcome to the community.
Can you try getting issue object in this way?
Issue issue = event.getIssue()
MutableIssue mIssue = (MutableIssue) issue
Also, check this documentation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
IssueEvent event = ComponentAccessor.getIssueEventManager().getEvent(issue.id)
Remove this, event is already in the binding, and that is what the static type checking is telling you.
def dateCf = customFieldManager.getCustomFieldObjectsByName("Follow up date")
This gives a list, not a single field. You could do .getCustomFieldObjectsByName("Follow up date").first() to get the first field from that list. All in all you'd probably be better off using an ID getter such as .getCustomFieldObject("customfield_11111") which will return just a single field.
def calendar = Calendar.getInstance()
calendar.time = new Date()
That's redundant, calendar already comes with current time so you don't need to override the time.
I am getting this error:
Variable "event" masks a binding variable of the same name. Please choose a different name for variable: "event"
No, that's not an error. It's static type checking which is more of a warning, but that's already covered in first block.
Lastly, you're setting the field value on the issue, but your issue is just in "memory" so to speak, basically you're just editing something in memory but never committing that change back to Jira.
After you modify the issue object, you can use IssueManager to make Jira save the changes:
mutableIssue.setCustomFieldValue(CustomField customField, Object value) // your line
issueManager.updateIssue(ApplicationUser updatingUser, mutableIssue, EventDispatchOption.DO_NOT_DISPATCH, false)
issueIndexingService.reIndex(mutableIssue, IssueIndexingParams.INDEX_ISSUE_ONLY) //optional, if you care about index being readily available
Which will require for you to have a user that will update the issue (updatingUser). Fortunately you could just reuse the same user that triggered the event (https://docs.atlassian.com/software/jira/docs/api/9.4.19/com/atlassian/jira/event/issue/IssueEvent.html) using event.getUser()
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.