Closed Warlib1975 closed 7 years ago
Hi. Try to use user
field format and put this code in formula field User.current.id
Hi,
cool! It works! Thank you.
Is it possible to "freeze" this field corresponding state and/or tracker? E.g. supporter with specific role (e.g. tester) change tracker to "Testing" and change state to "New testing" and pickup issue to workout. I need to fill field "Tested by:" with value of current user. Then approver change tracker to "Approve" and change the state to "Start approving" and gets the issue. And field "Approved by" should be filled by current user value, but the field "Tested by" should be "freezed". Then state can be returned back to Tracker "Testing" and new tester test the issue and in this case the new value should be place to field "Tested by:".
Thank you.
In "Tested by" field you should check if the current user has role "Tester":
if User.current.roles_for_project(project).include? TESTER_ROLE_ID
User.current.id
else
custom_field_value TESTED_BY_CF_ID
end
In "Approved by" field you should check if the current user has role "Approver":
if User.current.roles_for_project(project).include? APPROVER_ROLE_ID
User.current.id
else
custom_field_value APPROVED_BY_CF_ID
end
Hi,
thank you. That's perfect. Could you explain how I can get ID of statuses or roles?
Thank you.
Thank you. I thought that TESTER_ROLE_ID and APPROVER_ROLE_ID - it's unique database ID, but not symbolic name. So, in case of renaming statuses or roles calculated custom field will stop working. :-(
How to get the current issue status? I would like to change calculated custom field if user change status to some specific value.
If you rename a custom field its ID does not change.
Issue has a field status_id
.
Hm, at the page http://yourhost/roles only symbolic names of roles. E.g. if I make expression
if User.current.roles_for_project(project).include? 'Tester' User.current.id end
it doesn't work and I don't know how to debug it. :-(
I made a mistake in a previous formula.
# In my case Tester role ID is 4
if User.current.roles_for_project(project).map(&:id).include? 4
User.current.id
end
Hi,
Thank you. Now I understand.
Hi.
status_id
is not a class method, it is an instance method. In the formulas for IssueCustomField you should use just status_id
or self.status_id
.
Hi,
thank you. Now everything works perfect.
You're welcome. If you have no more questions, please close the issue.
One another thing. If I use expression if self.status_id == 10 User.current.id end
Practically everything works ok, except one thing, if the condition is false, the custom field value is emptied. As far as I understand I should return current value of custom field, but I don't know how to gets it.
if self.status_id == 10 User.current.id else .. end
Thank you.
I found the solution, but not perfect, I think
if self.status_id == 10 User.current.id else cfs[23] end
where 23 - is id of the current custom field. It would be nice to get current value of the custom field without using ID, or get current custom ID.
Your solution is correct.
Thank you
The solution is described here: http://www.bizkit.ru/2017/07/19/4582/
Hi,
is it possible to add current user name (who authorized) as value for your custom fields.
There is plugins http://www.redmine.org/plugins/assign_current_user, but its too simple and work only with one field.
Thank you.