Cloud Workflow

backlog Add Issue

Adds an Issue based on its Project ID, Summary, Type ID, etc., and stores the communication log into Data Item respectively.
Backlog Add Issue
backlog-issue-add-20171025-addonxml
(md5:2913e37f7c0a91f8e27edcdec0a8eb5d)

    • C’: Project ID stored in the selected Data Item at C
    • D’: Summary of the Issue stored in the selected Data Item at D
    • E’: Description of the Issue stored in the selected Data Item at
    • F’: Type ID of the Issue stored in the selected Data Item at F
    • G’: Priority ID of the Issue stored in the selected Data Item at G
    • H’: Assignee ID stored in the selected Data Item at H
    • I’: Due date stored in the selected Data Item at I
    • J’: Category ID stored in the selected Data Item at J
    • The communication logs will be stored in the data item selected at X
    • You need to obtain backlog’s API key beforehand with referring to this page

    A. Space idSingle-line inputRequired
    B. API keySingle-line inputRequired
    C. Select SELECT DATA for Project IdData selectSelect(radio/select/search)Required
    D. Select TEXT DATA for SummaryData selectString(single line)Required
    E. Select TEXT DATA for DescriptionData selectString(multiple line)
    F. Select SELECT DATA for Issue Type IdData selectSelect(radio/select/search)Required
    G. Select SELECT DATA for Priority IdData selectSelect(radio/select/search)Required
    H. Select SELECT DATA for Assignee IdData selectSelect(radio/select/search)
    I. Select SELECT DATA for Due DateData selectDate
    J. Select SELECT DATA for Category IdData selectSelect(radio/select/search)
    X. Select TEXT DATA for LogData selectString(multiple line)
    -variable namevariable label
    Aconf_SpaceIdSpace id
    Bconf_ApiKeyAPI key
    Cconf_ProjectIdSelect SELECT DATA for Project Id
    Dconf_SummarySelect TEXT DATA for Summary
    Econf_DescriptionSelect TEXT DATA for Description
    Fconf_IssueTypeIdSelect SELECT DATA for Issue Type Id
    Gconf_PriorityIdSelect SELECT DATA for Priority Id
    Hconf_AssigneeIdSelect SELECT DATA for Assignee Id
    Iconf_DueDateSelect SELECT DATA for Due Date
    Jconf_CategoryIdSelect SELECT DATA for Category Id
    Xconf_LogSelect TEXT DATA for Log
    //// == コンフィグの参照 / 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 );
    }