workflow to update issue state in target project, on change of issue state in source project

26 Views Asked by At

Summary

We have two projects:

  • Developer Project
  • Support Project

When customer raises an issue, the issue is raised in the Support Project. This automatically creates an issue in the Developer project with the relevant tags.

The issue created in the Developer project will have summary <support-issue-summary>/<support-issue-id>.

Currently, we are unable to automatically update states in the Support project based on change in state in the Developer project. Details are as follows:

Requirements

Our development team only reviews the Developer project. We want to sync changes in states in the Developer project to automatically update the relevant issue in the Support project.

The Developer and Support project should have separate states.

Implementation

After verifying the guard, and obtaining the relevant target issue ID etc. We use this try catch block to update the target issue state:

    // this version is working
    try {
      // If the current state of the linked issue is 'UAT-QAClosed', make it 'Pending Release'
      if(issue.fields.State.name === "UAT-QAClosed") {
        console.log("start to update the field...")
        targetIssue.fields.State = ctx.HelpDesk_State["InProgress"];
        }
    } catch(err) {
      console.log(JSON.stringify(err));
      console.log("Damn, this means there is an error...");
    }

Requirements block, for reference:

  requirements: {
    StateState: {
      name: "State",
      type: entities.State.fieldType,
      UATQAClosed: {name: "UAT-QAClosed"},
      "Pending Release": {name: "Pending Release"},
      InProgress: {name: "In Progress"},
      "SIT-Closed": { name: "SIT-Closed" } // New mapping
    },
   
   HelpDesk_State: {
      name: "State",
      type: entities.State.fieldType,
      UATQAClosed: {name: "UAT-QAClosed"},
      "Pending Release": {name: "Pending Release"},
      InProgress: {name: "In Progress"},
      "SIT-Closed": { name: "SIT-Closed" } // New mapping
    },
    
    project_0: {
      type: entities.Project,
      name: 'Test Project 14 Mar'
    }
}

Success -- If share same State Field

The target issue is updated successfully if both the Developer and Support project shares the same state fields

See here for reference!

Issue -- require assistance

However, when the fields are independent -- the try-catch block throws an error.

However, the error is undefined

Workaround

Currently, the workaround is to have both the Developer and Support project to use the exact same states. However, this is not a feasible option for us -- and we'd like to check in on any ways we can improve this?

0

There are 0 best solutions below