Backlog Add Issue
Adds an Issue based on its Project ID, Summary, Type ID, etc., and stores the communication log into Data Item respectively.
2018 (C) Questetra, Inc. (MIT License)
Configs
  • A: Space id *
  • B: API key *
  • C: Select SELECT DATA for Project Id *
  • D: Select TEXT DATA for Summary *
  • E: Select TEXT DATA for Description
  • F: Select SELECT DATA for Issue Type Id *
  • G: Select SELECT DATA for Priority Id *
  • H: Select SELECT DATA for Assignee Id
  • I: Select SELECT DATA for Due Date
  • J: Select SELECT DATA for Category Id
  • X: Select TEXT DATA for Log
Script
//// == コンフィグの参照 / Config Retrieving ==
var apiKey = configs.get("conf_ApiKey") + "";
var spaceId = configs.get("conf_SpaceId") + "";


//// == ワークフローデータの参照 / Data Retrieving ==
var projectId = engine.findDataByNumber( configs.get("conf_ProjectId") ).get(0).getValue() + "";
var summary = engine.findDataByNumber( configs.get("conf_Summary") ) + "";
var description = engine.findDataByNumber( configs.get("conf_Description") ) + "";
var issueTypeId = engine.findDataByNumber( configs.get("conf_IssueTypeId") ).get(0).getValue() + "";
var priorityId = engine.findDataByNumber( configs.get("conf_PriorityId") ).get(0).getValue() + "";

//以下は必須指定でないもの
var dataNum_AssigneeId = configs.get("conf_AssigneeId") + "";
var assigneeId;
if ((dataNum_AssigneeId !== "") && (engine.findDataByNumber( dataNum_AssigneeId ))) {
  assigneeId = engine.findDataByNumber( dataNum_AssigneeId ).get(0).getValue() + "";
}
var dataNum_DueDate = configs.get("conf_DueDate") + "";
var dueDate;
if ((dataNum_DueDate !== "") && (engine.findDataByNumber( dataNum_DueDate ))) {
  dueDate = engine.findDataByNumber( dataNum_DueDate ) + "";
}
var dataNum_CategoryId = configs.get("conf_CategoryId") + "";
var categoryId;
if ((dataNum_CategoryId !== "") && (engine.findDataByNumber( dataNum_CategoryId ))) {
  categoryId = engine.findDataByNumber( dataNum_CategoryId ).get(0).getValue() + "";
}


//// == 演算 / Calculating ==
//apiKey だけはクエリパラメータ
var request = httpClient.begin()
  .formParam( "projectId", projectId )
  .formParam( "summary", summary )
  .formParam( "description", description )
  .formParam( "issueTypeId", issueTypeId )
  .formParam( "priorityId", priorityId )
  .queryParam("apiKey", apiKey);
//以下は指定があれば
if (assigneeId) {
  request = request.formParam( "assigneeId", assigneeId );
}
if (dueDate) {
  request = request.formParam( "dueDate", dueDate );
}
if (categoryId) {
  request = request.formParam( "categoryId[]", categoryId );
}

var response = request.post( "https://" + spaceId + ".backlog.com/api/v2/issues" );


//// == ワークフローデータへの代入 / Data Updating ==
//ログデータの指定があれば
var dataNum_Log = configs.get("conf_Log") + "";
if (dataNum_Log !== "") {
  var log = "";
  log += "---POST request--- " + response.getStatusCode() + "\n";
  log += response.getResponseAsString() + "\n";
  engine.setDataByNumber( dataNum_Log, log );
}

Download

Capture

Notes

  • You need to obtain Backlog’s API key beforehand by referring to this page:

https://backlog.com/help/usersguide/personal-settings/userguide2378/

See also

%d bloggers like this: