add features to initiative as children (php api)

ぐ巨炮叔叔 提交于 2019-12-11 09:57:06

问题


How would I add a feature as a children to a pre-existing initiative? I would assume it's the same way you update a state in a feature:

Connection::rally()->update('feature', feature_objectId, array('state' => $stateId)); This is how I have the code to add (update children field) children (features) to an initiative:

Connection::rally()->update('initiative', '13298601606', array('children' => '13298601665')); The first object Id is for the initiative I would like to add the features to and the second id is of the feature being added as a child to the initiative.

Why is this not working? does someone have an idea on how to go around doing this?


回答1:


Children collection of Initiative object in WS API is read-only.

Here is a Ruby code that creates a new feature and adds it to an existing initiative by updating Parent field of the new feature:

require 'rally_api'


#Setup custom app information
headers = RallyAPI::CustomHttpHeader.new()
headers.name = "My Utility: add feature to initiative"
headers.vendor = "Nick M RallyLab"
headers.version = "1.0"

# Connection to Rally
config = {:base_url => "https://rally1.rallydev.com/slm"}
config[:username] = "user@co.com"
config[:password] = "secret"
config[:workspace] = "W1"
config[:project] = "P1"
config[:headers] = headers #from RallyAPI::CustomHttpHeader.new()

@rally = RallyAPI::RallyRestJson.new(config)

obj = {}
obj["Name"] = "new feature abc456"
new_f = @rally.create("portfolioitem/feature", obj)

query = RallyAPI::RallyQuery.new()
query.type = "portfolioitem/initiative"
query.fetch = "Name,FormattedID"
query.workspace = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/workspace/1111" } 
query.project = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/project/2222" }
query.query_string = "(FormattedID = \"I1\")"

result = @rally.find(query)
initiative = result.first

field_updates={"Parent" => initiative}
new_f.update(field_updates)


来源:https://stackoverflow.com/questions/18066126/add-features-to-initiative-as-children-php-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!