Script to update specific field on all issues in a project


#1

I am looking for a way to update all the fields within all the issues on a specific project. For instance, I have a field called #[ProjectType]# on all the issues on project 77, how do I update this field in all the project’s issues to a value such as “vulnscan”. Does anyone have a script that will do this?

TYIA,
–Jon


#2

Hi @jchase,

You need something that in spirit is similar to:

Pseudocode:

  1. Locate project
  2. Loop through Issues
  3. Update field
  4. Save issue

Real code:

project = Project.find( <id> )

Node.set_project_scope(project.id)
Note.set_project_scope(project.id)
Issue.set_project_scope(project.id)
Evidence.set_project_scope(project.id)
Tag.set_project_scope(project.id)

issue_library = Node.issue_library
Issue.where(node_id: issue_library.id).each do |issue|
  issue.set_field('ProjectType', 'vulnscan')
  issue.save
end