Hi All,
Currently, I have a Fast-track post function applied on my workflow which is transitioning the issues to next status based on the custom field values.
Ex- If Request type = XYZ then Issue moved From Manager Approval to Open Status.
But the issue is, currently it is running as default to CurrentUser and I want to change it to a Default user.
I created a script but it's not working. It is showing a warning on 'Issue issue = issue' Could you please assist?
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.Field
ApplicationUser targetuser = ComponentAccessor.userManager.getUserByName('Jira Service Management(Automation)')
Issue issue = issue
ScriptRunnerImpl.runWithUser(targetuser){
MutableIssue mutableIssue = ComponentAccessor.getIssueManager().getIssueObject(issue.id)
}
Hi @Manoj Gangwar,
I'm not sure if you have already found a solution for this.
Could you please clarify what version of Jira and ScriptRunner you are currently using?
Thank you and Kind regards,
Ram
Hi @Ram Kumar Aravindakshan _Adaptavist_ ,
We are using Scriptrunner version - 6.50.0 and Jira Version 8.20.27
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 getting back and providing the requested information.
It appears you are using an outdated version of ScriptRunner. Please upgrade your ScriptRunner plugin to version 8.17.0 or at least 7.13.0 so that you can use the HAPI feature.
If you intend for the Fast Track transition to execute as a different user, you can use this approach with ScriptRunner's HAPI, i.e.,-
Users.runAs('username') {
issue.issueType.name == 'Story'
}
You will need to add this condition to the Conditions field as shown in the screenshot below:-
For more information, you can refer to this ScriptRunner HAPI documentation.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ram Kumar Aravindakshan _Adaptavist_ ,
I am having the same request (to have the "fast forwad transition" beeing run as a user that we use for automation processes), but your solution unfortunately doesn't seem to work in my case. The transition is executed, but with the current user instead of the "runas-user".
Do you have an idea, what could be the issue here?
We are currently on scriptrunner v8.20.0 and jira v.4.9.18.
I use following condition in the fast forwar transition postfunction:
Users.runAs('bsm-admin') {
issue.getCustomFieldValue(12101) == null
}
Thank you a lot in advance,
Jeanette
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry for the late reply.
Looking at your code, it seems that you are performing a validation to check that the Custom Field doesn't have a value. There doesn't appear to be any task after that, so you do not see any output.
You need to try something like:-
Users.runAs('bsm-admin') {
issue.getCustomFieldValue('Some Field Name').toString().length() == 0
}
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ram Kumar Aravindakshan _Adaptavist_ ,
thank you for the response.
Yes, I want to check, if the customfield, which is a multi selection field type, has no checked values and if so, the issue should be transitioned to another status. The transitioning should be run as the admin user.
As the gestCustomfieldValue.toString() returns "null" the length returns 4, I changed it to
Users.runAs('bsm-admin') {
issue.getCustomFieldValue(12101).toString() == 'null'
}
But I still get the same result: the issue is transitioned, but with my user account instead of the defined admin account.
The code needs to be in the "Condition" part and not in the "Additional issue actions" part, doesn't it?
Thank you and best regards,
Jeanette
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Jeanette Seewald did you find the reason it is recording th tranistion as current user instead of the RunAs ?
I face the same issue
thanks for your feedback
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ram Kumar Aravindakshan _Adaptavist_ , we have exactly the same thing . it is not working and transition is recorded as beeing executed as current user
In our condition we simply have :
Users.runAs('automation_user') {
//We simply check here that the Reuest type is matching
... code omited
}
In additonnal issue Action we have a simple script which write a comment to the issue
We are using Script runner 8.36 amd JIra 9.12.15
Any idea wy the runAs is not working ?
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @serge calderara ,
I created a ticket at the scriptrunner portal then, but they told me that this is not a feature that is available for data center and referred me to a development ticket ([SRJIRA-4350] Run as User functionality for 'Fast-track Transition an Issue' on SR4J - Managed Services Support Portal)
Unfortunatly, the portal this ticket seems to belong to is outdated and I don't know if this feature request was also transferred to the new portal.
I went back using the postfunction provided by the JWT PlugIn, which has a "run as" feature.
But if you get any new information on that topic, I would appreciate any update :)
Best regards,
Jeanette
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.