redmine_custom_workflows icon indicating copy to clipboard operation
redmine_custom_workflows copied to clipboard

Change status based on custom field && current status

Open Salam5071 opened this issue 2 years ago • 3 comments

Hi all master!! I'm not a developer or programmer but this task assigned for me. I need your good help on his.

Attached is the flowchart for this project. GREEN colored words is can be manually assigned the status. BLUE colored words is to be automatically assigned the status when got decision selection.

Below is my code. #Check if "Further clarification needed?" AND issue status = Technical Spec Understanding self.status_id = 37 if (custom_field_value(28) == 'Yes') && @issue.status_id==36 #If Yes, issue status will be set into = Technical Spec Clarification self.status_id = 38 if (custom_field_value(28) == 'No') && @issue.status_id==36 #If No, issue status will be set into = Pending Development

#Check if "Revise Technical Specification" AND issue status = Technical Spec Clarification self.status_id = 39 if (custom_field_value(29) == 'Yes') && @issue.status_id==37 #If Yes, issue status will be set into = Technical Specification Revise self.status_id = 38 if (custom_field_value(29) == 'No') && @issue.status_id==37 #If No, issue status will be set into = Pending Development

#Check if "Resubmission Technical Specification" AND issue status = Technical Specification Revise self.status_id = 36 if (custom_field_value(24) == 'Yes') && @issue.status_id==39 #If Yes, issue status will be set into = Technical Spec Understanding

#Check if "Approval 1st Level Code Review" AND issue status = Developer Code Review self.status_id = 44 if (custom_field_value(30) == 'Yes') && @issue.status_id==42 #If Yes, issue status will be set into = Project Team Lead Code Review self.status_id = 43 if (custom_field_value(30) == 'No') && @issue.status_id==42 #If No, issue status will be set into = Developer Revise Code Review

#Check if ""Approval 2nd Level Code Review" AND issue status = Project Team Lead Code Review self.status_id = 45 if (custom_field_value(31) == 'Yes') && @issue.status_id==44 #If Yes, issue status will be set into = Check in to SVN self.status_id = 46 if (custom_field_value(31) == 'No') && @issue.status_id==44 #If No, issue status will be set into = Developer Revise Code Review

My Question:

  1. How to make the custom field value become blank again after the process is back to the previous status so that we can make the decision selection again?

image

Salam5071 avatar Feb 23 '23 09:02 Salam5071

I am not sure if understand your problem correctly but ActiveModel provides _was methods to access previous value of a filed. In your case self.status_id_was will be pointing to the previous status.

Wrap it into an if statement:

# Issue status was changed from 45 => 44
if self.status_id_changed? && self.status_id_was == 45 && self.status_id == 44
# do smth
end

dmakurin avatar Feb 23 '23 23:02 dmakurin

if self.status_id_changed? && self.status_id_was == 45 && self.status_id == 44
# do smth
end

Hi Dmakurin,

I've tested your advise, but still the same..

For simplify, I want to set the status automatically when user do the decision "Technical Specification Revise" = Yes or = No. As you can the flowchart below, there are looping. So when the status changed to Technical Spefication Review for 2nd time, the issue will automatically set the status into Technical Specification Revise again as the selection remain "Yes".

Example code. #set the status into "Technical Specification Revise" if field "Revise Technical Specification = Yes" && current status "Technical Spec Review" self.status_id = 39 if (custom_field_value(29) == 'Yes') && @issue.status_id==31 #set the status into "Technical Spec Assign" if field "Revise Technical Specification = No" && current status "Technical Spec Review" self.status_id = 32 if (custom_field_value(29) == 'No') && @issue.status_id==31

image

Salam5071 avatar Mar 02 '23 03:03 Salam5071

may be it will be useful as idea: add some version, that will up each round. If version become too high - make custom_field blank.

qawsed55 avatar Mar 12 '23 18:03 qawsed55