Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To prevent user error when creating a work item, you set the default Assignee for the Work Item to the user who created the work item if it was not set. This webhook will only set the assignee at creation time using the Work Item Created Event.

Webhook Listener

Code Block
languagegroovy
FlxWorkItemDataObject workItem = FLEXDEPLOY.findWorkItemByNumber(EVENT.payload.workItemNumber)

// check if the assignee is not already set
if (!workItem.getAssignee()?.trim())
{
  FLEXDEPLOY.updateWorkItemAssignee(EVENT.payload.workItemNumber, EVENT.payload.createdBy)
}

...

Select the Event Types as Project Created from the drop-down

...

Code Block
languagegroovy
import flexagon.fd.model.pojos.rest.project.*;
import flexagon.fd.model2.pojo.ProjectDataObject;

LOG.info("Running listener: ${FUNCTION_NAME}");
LOG.info(EVENT.payload.projectName);

def projectDataObject = new ProjectDataObject();
projectDataObject.setProjectId(EVENT.payload.projectId);

def resProjects = FLEXDEPLOY.searchProjects(projectDataObject,10,0).getItems();

def proj = new ProjectPojo();
proj.setWebhooksEnabled(true);

for (def project:resProjects)
{
  def projectId = project.getProjectId();
  FLEXDEPLOY.patchProject(projectId, proj);
}
LOG.setMessage("Webhook is now enabled for Project " + EVENT.payload.projectName);

...