Hi All,
I have written the below script for creating the issue in Jira, but getting issue created.
import com.atlassian.jira.bc.issue.IssueService.CreateValidationResult
import com.atlassian.jira.bc.issue.IssueService.IssueResult
import com.atlassian.jira.issue.IssueManager
import org.apache.log4j.Category
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.*
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.bc.issue.IssueService;
import com.atlassian.jira.bc.issue.IssueService.CreateValidationResult;
import com.atlassian.jira.bc.issue.IssueService.IssueResult;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
Collection<CustomField> customFields = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectsByName("customFieldId=18229");
println(customFields);
for (CustomField customField : customFields) {
if (customField.getValue(issue).toString().equals("Yes")) {
//customField=Yes, create issue
IssueService issueService = ComponentAccessor.getIssueService();
println(issueService);
CreateValidationResult createValidationResult = issueService.validateCreate(currentUser, issueInputParameters);
println(issueService);
if (createValidationResult.isValid())
{
IssueResult createResult = issueService.create(currentUser, createValidationResult);
if (!createResult.isValid())
{
println("issue created");
}
}
}
}
Any help/Suggestion would be appreciated.
Regards,
Dileep Kumar
Why are you creating a script for it? what's your use-case as it's generally supported by script runner to create an issue at workflow post-function.
Hi Tarun,
Thanks for the help !!
I want the script which will create the issue/sub-task based on given Custom Field.
Suppose if CodeReview(Custom Field) is yes then issue/sub-task should be created.
After this created issue, i want it to link with another issue.
This is my overall requirement.
Can you please help me with the groovy script for above requirement ?
Regards,
Dileep Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you have script runner plugin then it's a built-in post function to create a sub-task or to create an issue. You don't have to write a script for it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
And you can easily add a condition before the execution of the post-function, and if the condition is true only then the post-function will be executed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tarun,
Thanks for the help !!
I will check it, if any issue will let you know.
Regards,
Dileep Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tarun,
Yes, you are right. The feature is available, but i need to automate this feature by using custom script. So i want the groovy script.
If you can help, it would be great !!
Regards,
Dileep Kumar
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.