Hi there,
would like to add a comment into a workflow on transition but would like that comment to be the same every time with the exception that some data from the issues is used in the comment such as CurrentAssignee and NewAssignee.
I have used this script and it works fine
---
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.comments.CommentManager
import com.opensymphony.workflow.WorkflowContext
import org.apache.log4j.Category
String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller();
commmgr = (CommentManager) ComponentManager.getComponentInstanceOfType(CommentManager.class)
commmgr.create(issue, currentUser, "I resolved this issue even though there are unresolved sub-tasks... slapped wrists", true)
issue.store()
---
but I would like to add carriage returns and variables like this
---
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.comments.CommentManager
import com.opensymphony.workflow.WorkflowContext
import org.apache.log4j.Category
String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller();
commmgr = (CommentManager) ComponentManager.getComponentInstanceOfType(CommentManager.class)
commmgr.create(issue, currentUser, "$NewAssigneeFirstName$,
Please proceed with this task. Please revert back if you have any questions.
Thanks,
$CurrentAssigneeFirstName", true)
issue.store()
---
Could you please tell me how I would achieve this result,
Thanks
Frank
Hi Frank,
You've actually almost did it yourself! You can cast variables into a string using GStrings, like so:
String sampleString = "This issues's key is ${issue.getKey()}"
This example will return: "This issue's key is ABC-123"
Thanks Ivan,
I can't take credit for that script above - I found that at https://scriptrunner.adaptavist.com/
thanks for the input - I will test and see how I go,
cheers
Frank
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline 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.