2013-10-09 34 views
1

在作爲工作空間管理員的Rally中,可以將值添加到用戶故事(或缺陷)上的排定狀態字段的下拉列表中。如何通過API查詢自定義排定狀態

有沒有辦法通過API來查詢用戶故事中的調度狀態的下拉列表值?

我試圖解決的問題是我們有自定義的報告,我們正在使用各種工作區,但是現在有一個工作區要求定義之前和接受之後的狀態。我寧願爲每個工作區的每個自定義報告創建新版本來處理自定義狀態,我寧願在該工作區中查詢用戶故事的有效安排狀態,然後在自定義報告中執行任何顯示狀態所需的操作。

值得一提的是,這是在v1.43中,因爲這些自定義報告使用LoginKey在Rally之外運行。

回答

1

下面是一個AppSDK 1.33例如:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html> 
<head> 
    <meta name="Name" content="App Example: Attribute Values" /> 
    <title>Attribute Values Example</title> 
    <script type="text/javascript" src="https://rally1.rallydev.com/apps/1.33/sdk.js?apiVersion=1.43"></script> 
    <script type="text/javascript"> 

    function attributeQueryExample() { 

    var showAttributeValues = function(results) { 
     var aDiv = document.getElementById("aDiv"); 
     aDiv.innerHTML = '<b>attributeQueryExample</b><br>'; 
     for (var property in results) { 
     aDiv.innerHTML += "&nbsp;<b>" + property + "</b><br>"; 
     for (var i=0 ; i < results[property].length ; i++) { 
      aDiv.innerHTML += "&nbsp;&nbsp;" + results[property][i] + "<br>"; 
     } 
     } 
    }; 

    var queryConfig = []; 
    queryConfig[0] = {type: 'Hierarchical Requirement', 
      key : 'storyStates', 
      attribute: 'Schedule State' 
      }; 
     queryConfig[1] = {type: 'Defect', 
      key : 'defectStates', 
      attribute: 'Schedule State' 
      }; 

    var rallyDataSource = new rally.sdk.data.RallyDataSource('1111', '2222','false', 'false'); 
    rallyDataSource.findAll(queryConfig, showAttributeValues); 
    } 

    rally.addOnLoad(attributeQueryExample); 

    </script> 
</head> 

<body> 
    <div id="aDiv"></div> 
</body> 
</html> 

的截圖:

enter image description here

+0

謝謝! - 我以爲有類似State字段的內容(https://rally1.rallydev.com/slm/doc/webservice/objectModel.sp#State),但對於ScheduleState來說,它不僅顯示允許的值,而且不管是之前已啓用,但之後被禁用 - 但對於ScheduleState而言似乎不可能存在。 –

3

此代碼將爲您提供用戶故事的所有可用日程安排狀態數組。指定工作區OID以獲取不同工作區的不同值。

Rally.data.ModelFactory.getModel({ 
    type: 'HierarchicalRequirement', 
    context: { 
     workspace: '/workspace/12345' 
    }, 
    success: function(model) { 
     var stateNames = Ext.Array.pluck(model.getField('ScheduleState').allowedValues, 'StringValue'); 
    } 
}); 
+0

嗨康納!感謝您的快速響應,但不幸的是我沒有使用SDK2.0,因爲有問題的報告使用LoginKey運行在Rally之外(據我所知,這在SDK2.0中不可用)。 - 你有沒有辦法在SDK1.32(使用API​​ v1.43)中做到這一點? –