redmine_custom_workflows icon indicating copy to clipboard operation
redmine_custom_workflows copied to clipboard

Can't change issue's subject in before_save procedure

Open msneet opened this issue 8 years ago • 4 comments

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?

msneet avatar Apr 22 '16 11:04 msneet

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?

FollM avatar Oct 18 '17 07:10 FollM

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,
        ...

gferley avatar Feb 18 '19 22:02 gferley

my solution is to use plugin https://github.com/annikoff/redmine_plugin_computed_custom_field and set subject in computed field self.subject = "testsubject"

msneet avatar Dec 27 '19 08:12 msneet

Hi,

Agree, we have only dirty hack solution for that. Check this: https://github.com/anteo/redmine_custom_workflows/issues/226#issuecomment-945634288

AirTibu avatar Jul 14 '22 00:07 AirTibu