Comments (9)
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.
thanks for posting your solution!! :)
from redmine_custom_workflows.
No problem... Very glad to help where I can...
from redmine_custom_workflows.
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.
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.
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.
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.
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.
Excellent! I knew that it would be something like that. Glad to help.
from redmine_custom_workflows.
Related Issues (20)
- Custom tables plugin HOT 7
- rake task with custom workflow HOT 3
- Script to switch status HOT 1
- Set custom filed only when issue is created, not changed HOT 1
- Access custom field data HOT 2
- float value HOT 1
- Interference with other redmine-plugins HOT 7
- sum depend in the tow custom filed HOT 18
- Problem with upgrading from 2.0.3 to 2.0.9 HOT 1
- pulk value from contacts redmineup plugin
- Actions possible on new tickets HOT 2
- get Post call value before_save using params[:id] HOT 4
- get the last value and last update value in custom field HOT 3
- Mail sending from custom workflows HOT 2
- Help needed with custom_field date type HOT 4
- Send mail to the author when an issue is created HOT 3
- Help! HOT 2
- Assign anotther tracker to quto created subtask HOT 2
- Project custom Field
- parent_done_ratio float round(2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redmine_custom_workflows.