Issue Creation Plugin
Added by Rick Barrette almost 13 years ago
Hello,
I am currently writing a plugin the creates a new issue via a http post request. I am currently Having issues with creating and saving a new issue. I was hoping that someone would point me in the right direction. Thank you in advance
issue = Issue.new
issue.tracker = Tracker.find_by_name("Bug")
issue.subject = params[:subject]
issue.description = params[:description]
issue.project = Project.find_by_name(params[:project])
issue.start_date = Time.now.localtime.strftime("%Y-%m-%d")
issue.priority = IssuePriority.find_by_name("Normal")
issue.author = User.find_by_mail("XXX@gmail.com")
issue.status = IssueStatus.find_by_name("New")
issue.save
Replies (2)
RE: Issue Creation Plugin - Added by Rick Barrette almost 13 years ago
After calling `issue.errors.full_messages` , I discovered that I could not save the issue because required custom fields were not set.
I added the following code before calling issue.save
issue.custom_values = [
create_custom_value(CustomField.find_by_name("StackTrace").id, params[:stackTrace]),
... more custom values ...
]
also here is my create_custom_value method
# returns a new custom value
def create_custom_value(field_id, value)
custom_value = CustomValue.new
custom_value.custom_field_id = field_id
custom_value.value = value
custom_value.customized_type = "Issue"
return custom_value
end
RE: Issue Creation Plugin - Added by anish shah about 11 years ago
i am facing almost same problem any help.....