redmine_custom_workflows
redmine_custom_workflows copied to clipboard
How to change the assignee to their group
Hi all What the code if the user create issue the assignee her group
Hi,
There is a logic error in this request. If I understand correctly, the request is that if a user creates an issue, the issue assignee should be the group of which the user is a member.
The problem with this is that a user can be a member of several groups, if a user is in 3 groups, which group should be assigned to the issue as assignee?
The code below assigns the first group in which the user who created the issue is included:
self.assigned_to = User.current.groups.first
I hope it helps!
how i can choose (assigned_to_id) from array and this group_id and each group_id for only one project in my case
if [1, 3, 7, 8, 18, 12, 10, 6, 55, 13] include?(status_id)
self.assigned_to = [149, 25, 27, 34, 46, 9, 18, 20, 24, 15, 14, 53] .include?(assigned_to_id)
end
the answer is one form assigned _to_id ,and this id its currently member in project thx @AirTibu for your help
@AirTibu any news
How I can choosing the first option group
Hi,
I'm not sure if I understand your intent correctly, but if everything is correct, you want this:
- You have a user, who is the assignee.
- Find this user's group, which group is a member of this project
- Add this group to the issue as assignee
If so, then use this code
self.assigned_to_id = = (Project.find(self.project_id).principals.pluck(:id) & User.find(assigned_to_id).group_ids).first if assigned_to_id && project_id
I hope it helps!
Thx for replying me In my case The user assigned for another group he not member
I'm using the JavaScript to choose first option in list groups But I need it in custom work flow
If status id 1 then assigned to id ( First option in list groups)
$('#issue_assigned_to_id').val($('#issue_assigned_to_id > optgroup > option:nth-child(1)').val());
Hi,
Ok, I understand now. Try this code:
@my_group_ids = [149, 25, 27, 34, 46, 9, 18, 20, 24, 15, 14, 53]
@group_to_assignee = @my_group_ids.index(status_id.to_i)
self.assigned_to = Group.find(@group_to_assignee.to_i) unless @group_to_assignee.nil?
I hope it helps!