Coder Social home page Coder Social logo

Comments (9)

carukc avatar carukc commented on August 14, 2024

OK... for anyone else who stumbles this way... here's how:

booking = Issue.create!(
:author => User.current,
:project => project,
:tracker_id => 11,
:parent_issue_id => id,
:subject => "Reservation",
:description => description,
:custom_field_values => {36 => self.custom_field_value(36).to_s})

where 36 is the ID of the target custom field.

I'm not sure if the to_s is required.

from redmine_custom_workflows.

ElskerDane avatar ElskerDane commented on August 14, 2024

thanks for posting your solution!! :)

from redmine_custom_workflows.

carukc avatar carukc commented on August 14, 2024

No problem... Very glad to help where I can...

from redmine_custom_workflows.

ElskerDane avatar ElskerDane commented on August 14, 2024

Question for you carukc; I am very new to this plugin, and I was wondering how you go about determining what the ids of various items are? Such as custom fields, statuses, ect. You seem like a knowledgeable fellow, so I thought I would pose the question to you. :)

from redmine_custom_workflows.

carukc avatar carukc commented on August 14, 2024

Hi Again... sure... very pleased to help. I went directly to the database for the ID numbers.

custom fields are all stored in the custom_fields table, status IDs are all stored in the issue_status table. Unfortunately using the values directly from the tables would not be particularly portable. There must be an API call that would allow you to get the IDs from the names but I was less worried about portability than I was about just getting something working.

The rest was pure ruby... @issue for the current issue, self for the current object, etc... so I suspect that most things that would work directly within a plugin would work within the custom workflow code.

knowledgeable... hmmm not so sure... I'm very new to ruby myself so am figuring alot of things out as I go

from redmine_custom_workflows.

ElskerDane avatar ElskerDane commented on August 14, 2024

Thank you for being so helpful! I was able to find the IDs I was searching for.

I don't suppose I can push my luck and ask you if you have any idea how to assign other users to an issue? "User.current" is used in all the examples, but I would like to assign someone besides the current user. If you have any ideas, they would be much appreciated.

from redmine_custom_workflows.

carukc avatar carukc commented on August 14, 2024

Hi, no problem.

The user object seems to have quite a few methods. How do you want to specify the User? By ID? By username? I found this documentaiton for the user object: http://www.rubydoc.info/github/redmine/redmine/User

If you want to specify by mail address for example I imagine that it would be a matter of instantiating a user object and then using the appropriate method... any of the .find_by... look promising and then using the returned object to get the user ID. You might even be able to use that method with the User object noted in the docs but I'm not competent enough yet in ruby to know how all this works.

Does that make sense? If I can think of another way I'll post here... Please do let me know if you find a solution.

from redmine_custom_workflows.

ElskerDane avatar ElskerDane commented on August 14, 2024

Using your guidance @carukc I was able to figure it out!

For example, if you want to set the assignee whenever an issue's status is changed, your code would look like this:

before_save

@need_create = status_id_changed? && !new_record?

after_save

if @need_create
assigned_to = User.find_by_login('testuser2')
end

Thanks again for your help!

from redmine_custom_workflows.

carukc avatar carukc commented on August 14, 2024

Excellent! I knew that it would be something like that. Glad to help.

from redmine_custom_workflows.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.