Need user name for the custom 'Modified By' field when ever the Test case is modified.
The user who modifies a test case is captured. How do I use lastupdated function in JIRA scriptrunner
I'm sorry, I do not understand the question.
It sounds like you want to read a field from some issues, but JQL is about finding issues, not reading fields, so I'm lost on that. And what "user name" part of the "modified by" - which field are you actually interested in and which user name?
Use of SRs lastupdated function is documented at https://docs.adaptavist.com/sr4js/latest/get-started/tutorials/jql-functions-tutorial near the bottom of the page.
I have a field by name Modified By . Any time the test issue type is updated or edited. The Modified by field should display the persons name who modified it.
Looking for solutions using script runner.
So nothing to do with JQL or searching.
You could write a scripted field to drag it out of the history and comments, or you could write a listener to pick up all the change events (edit, assign, comment, transition, etc) and populate the field with the person who triggered the event.
Please share scripted field code
A similar code is mentioned here:
https://community.atlassian.com/t5/Jira-questions/Updating-a-custom-field-from-a-script-listener/qaq-p/759053
As @Nic Brough -Adaptavist- mentioned you can tweak the code by getting the logged in user and setting the 'modifed by' custom field. You can get the logged in user by:
def LoggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
Hope that helps.
Regards,
Anzar Khan
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.event.type.EventDispatchOptionimport com.atlassian.jira.issue.Issuedef issue = event.issue as Issuedef desiredValue = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() //TODO: Change this to be the actual calculation you wantdef customFieldName = "Modified By" //TODO: Change this to match the custom field you wantdef customFieldManager = ComponentAccessor.customFieldManagerdef field = customFieldManager.getCustomFieldObjects(issue).find{ it.name == customFieldName}def currentCustomFieldValue = issue.getCustomFieldValue(field)if (currentCustomFieldValue == desiredValue) { return //Quit -- we don't want to update the field if it's already correct.}def issueService = ComponentAccessor.getIssueService()def issueInputParameters = issueService.newIssueInputParameters()issueInputParameters.addCustomFieldValue(field.id, desiredValue)def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUserdef validationResult = issueService.validateUpdate(loggedInUser, issue.id, issueInputParameters)if (validationResult.isValid()) { def updateResult = issueService.update(loggedInUser, validationResult, EventDispatchOption.DO_NOT_DISPATCH, //This is important to avoid infinite loops false) if (!updateResult.isValid()) { log.error "Failed to update issue $issue.key" log.error updateResult.errorCollection.errorMessages log.warn updateResult.warningCollection.warnings }} else { log.error "Failed to update issue $issue.key" log.error validationResult.errorCollection.errorMessages log.warn validationResult.warningCollection.warnings}
It looks like you're new here. Sign in or register to get started.