redmine_custom_workflows
redmine_custom_workflows copied to clipboard
Can't change issue's subject in before_save procedure
None of this methods works
subject = self.custom_field_value(218)
subject = "asdf"
self.safe_attributes = {:subject => self.custom_field_value(218).to_s}
How to change issue's subject?
Hi, did you ever find a solution for this? I am having the exact same problem and may shed some more light on it: code like this:
self.subject = "testsubject"
self.safe_attributes = {subject: "testsubject"}
only works in before_save when a subject is already present. I am trying to create a subject on new tickets, so the user won't have to enter one at all. But it seems the validation for a ticket's subject kicks in before the custom workflows script, and tells me the subject is empty.
Does anyone know a workaround for this? Or another way to avoid users having to provide an issue subject?
Not sure if this helps, but had similar issue when creating an issue on project creation. My script was only validated and saved after I did an existence check on the field I was using for the subject of the new issue.
In my case, using the project's identifier (and setting @need_create in the before_save) my first line in the after_save script became:
if @need_create and identifier?
issue = Issue.new(
:author => User.current,
:project => self,
:subject => identifier,
...
my solution is to use plugin https://github.com/annikoff/redmine_plugin_computed_custom_field and set subject in computed field self.subject = "testsubject"
Hi,
Agree, we have only dirty hack solution for that. Check this: https://github.com/anteo/redmine_custom_workflows/issues/226#issuecomment-945634288