RallyDataSource.update is not working for portfolioitem/feature (works for userstories) - rally

Here is the API verison I am using:
script type="text/javascript" src="/apps/1.33/sdk.js?apiVersion=1.43"></script>
The goal is to display a portfolio item/feature and all the child user stories of the feature in a grid. Then based on the US fields value, update the value of the field of the portfolio item/feature.
I am able to update the release field of a UserStory using rallydatasource.update command, but the same command doesn't work for updating fields of portfolio item/feature
Here are the fields I am trying to update for Feature. These do not work
rallyDataSource.update({_ref:ref, GroomingState: nfGroomingState},onUpdateComplete,onError);
rallyDataSource.update({_ref:ref, c_GroomingState: nfGroomingState},onUpdateComplete,onError);
rallyDataSource.update({_ref:ref, Ready: true},onUpdateComplete,onError);
rallyDataSource.update({_ref:ref, Notes: "This is test"},onUpdateComplete,onError);
rallyDataSource.update({_ref:ref, Architect: "XYZ ABC"},onUpdateComplete,onError);
Here are the fields I am trying to update for UserStory. This does work.
rallyDataSource.update({
"_ref":sRef,
"Release": [
{
ref:relRef
}
]},
onUpdateComplete,onError);
Can someone please help me understand if there is something I am doing wrong?
Is update to portfolio item not supported in v 1.43?

You are using a trick ?apiVersion=1.43 to set the WS API version to the version the legacy AppSDK1 predates and does not support, and it works to the extent but not enough to get the updates working.
I suggest AppSDK2
Also, since State of PI types is a full object (unlike State or ScheduleState of Defects or UserStories) a _ref has to be used in this code: GroomingState: nfGroomingState You may be using the reference, it was not clear from the code fragment. There is a Ruby example here that works with PI states. Rally Ruby toolkit sits on the same WS API model, so that example is not entirely irrelevant.
Here are the details of what I tried with AppSDK1 set to use version 1.43 of WS API.
Regardless how I set the version either using src="/apps/1.33/sdk.js?apiVersion=1.43" or rallyDataSource.setApiVersion("1.43"); I have to use parent type:
PortfolioItem
instead of concrete PortfolioItem/Feature type when I query:
function itemQuery() {
var queryObject = {
key: "pi",
//type: "PortfolioItem/Feature", //does not work
type: "PortfolioItem",
fetch: "FormattedID,Parent,State,Name",
query: "(Parent.FormattedID = I8)"
};
rallyDataSource.findAll(queryObject, populateTable);
}
This works fine, and all children of PortfolioItem/Initiative I8, which are of type PortfolioItem/Feature are returned successfully, and if all I want to do is to build a grid, it works:
function populateTable(results) {
var tableDiv = document.getElementById('aDiv');
for (var i=0; i < results.pi.length; i++) {
var config = { columns:
[{key: 'FormattedID', header: 'Formatted ID', width: 100},
{key: 'State.Name', header: 'State', width: 100},
]};
var table = new rally.sdk.ui.Table(config);
table.addRows(results.pi);
table.display(tableDiv);
};
Two features are returned, one that has State already set, the other with no State:
However if I try to add the update function:
function populateTable(results) {
var tableDiv = document.getElementById('aDiv');
for (var i=0; i < results.pi.length; i++) {
if(results.pi[i].State === null){
console.log('state:',results.pi[i].State)
rallyDataSource.update({"_ref":results.pi[i]._ref, "State": "https://rally1.rallydev.com/slm/webservice/v2.0/state/12352608621"});
}
}
//...
"Requested type name "feature" is unknown error is returned:
OperationResult: ObjectErrors: Array[1]0: "Requested type name "feature" is unknown."length: 1__proto__: Array[0]Warnings: Array[1]0: "Please update your client to use the latest version of the API. You can find the latest version at https://rally1.rallydev.com/slm/doc/webservice/index.jsp?version=v2.0. No new projects should use this version of the API as it will be removed in the future."length: 1
AppSDK1 works with WS API that is no longer supported. Last supported date for 1.43 was June 20 of this year. AppSDK1 stopped at 1.32 of WS API. That is the reason for the trick to set WS API version because PortfolioItems were introduced in 1.37 of WS API. Particularly when you use features introduced after AppSDK1 was no longer updated (see WS API versioning) there is no guarantee that the rallyDataSource.setApiVersion("1.43"); trick will work in all scenarios.

Related

dojo1.10 Dynamic update of dijit.form.Select

I was trying to asynchronously update a Select field via Memory and ObjectStore. This doesn't work. Setting the data to the Memory object before creating the Select element works fine. Updating the Memory object after creating the Select element doesn't work anymore.
Example code:
require([
"dojo/ready",
"dijit/form/Select",
"dojo/store/Memory",
"dojo/store/Observable",
"dojo/data/ObjectStore",
'dojo/domReady!'
], function(ready, Select, Memory, Observable, ObjectStore, dom){
ready(function() {
var mymem = new Memory();
var myobs = new Observable(mymem);
var mystore = new ObjectStore({ objectStore: myobs });
/* updating memory here works :) */
//mymem.setData([ { id: 2, label: 'qwertz2' }, { id: 3, label: 'qwertz3' } ]);
var s = new Select({
store: mystore
}, 'appsAdminQueueContainer');
s.startup();
/* updating memory here doesn't work :( */
mymem.setData([ { id: 2, label: 'qwertz2' }, { id: 3, label: 'qwertz3' } ]);
});
}
);
Real working example: https://jsfiddle.net/mirQ/ra0dqb63/5/
Is this a bug or is there a solution to be able to update the content of the Select field after creating it - without having to access the Select field directly?
UPDATE
Thank you for your response.
The use of dojo/ready was just a missed leftover while simplifying my code, sorry.
That the use of the ObjectStore is not necessary was not clear to me. Thanks for clearing up.
Okay, the real problem seems to be indeed the last point. I think I have to extend my description.
Updated/extended problem description:
I'm using a grid. At first I was using dojox/grid/DataGrid, but then I switched to dgrid. Everything works well, but I want to use dijit.form.Select as editor for one column. This works also well if the data is static. But in one column I have to read dynamic data from the server. This data comes in JSON format.
First I tried to solve this with the use of dojo/data/ItemFileReadStore - that worked. But it's deprecated and I need to implement a formatter for that column that has to have access to the same JSON data read from the server. I don't have the code for that solution anymore, but it didn't work. I wasn't able to successfully query the data from within the formatter function.
Then I switched to Memory and xhr. The response from the server comes after the Memory object is created (and, as it seems, after creating the Select), so I had to use setData to bring my loaded data in the store. And because the Select is only an editor of a grid, I don't have access to the object itself to be able to re-set the store after updating the data.
I hope my extended description makes my real problem a bit clearer. Thanks in advance for your help!
Mirko
This works for me:
require([
'dijit/form/Select',
'dojo/store/Memory',
'dojo/store/Observable',
], function (Select, Memory, Observable) {
var mymem = new Memory({
data: [{
id: 2,
label: 'qwertz2'
}, {
id: 3,
label: 'qwertz3'
}]
});
var myobs = new Observable(mymem);
var s = new Select({
labelAttr: 'label',
store: myobs
}, 'appsAdminQueueContainer');
s.startup();
myobs.add({ id: 4, label: 'qwerty' });
});
Notable changes:
There's no reason to use dojo/ready in this code. The require callback already waits for modules to load, and as long as this script is at the bottom of the body, there's no need to wait for the DOM to load, either.
There's no need to use a dojo/data store adapter. dijit/form/Select supports dojo/store as well (as of 1.8 if I recall correctly). This might also have been why observation wasn't working. The only difference is labelAttr must be specified on the Select since dojo/store has no concept of a label property.
(Edit) now that I re-read the question, I notice you are calling setData. setData does not fire observers. setData completely resets the store's data, and to reflect that, you would need to actually reset the store on the select entirely (which requires calling setStore, not set('store', ...), if you are using 1.9 or earlier, because Select was never updated properly to support the set API until 1.10).
(Edit #2) Given that the primary reason you are calling setData is due to creating the store before actually having data for it, your case would probably be greatly simplified by using the RequestMemory store implementation from dojo-smore. It basically re-adds the url support that dojo/data/ItemFileReadStore had but dojo/store/Memory didn't.

Grouping WSAPI data store by Parent Name

I am creating a rallygrid component and would like to have the grid items grouped by their parent's Name attribute (bonus if I could also display the ID of the parent). I added the groupBy:'Parent' configuration to the storeConfig of the grid and was surprised that no results were returned. I also tried using groupBy:'Parent.Name' but still nothing.
I know this is possible with other fields such as Owner, but I'm at a loss as to why the Parent wouldn't be usable as well. Is this a bug, or am I setting the config up incorrectly?
Thanks
Change the storeConfig to keep the records from trying to update after being grouped:
storeConfig : {
remoteSort : false,
remoteGroup : false,
remoteFilter : false,
}
Add a listener to the load event which assigns a root level property to the record and groups by that record value. (For some reason store.group('Parent.Name'); doesn't work.)
load: function(store) {
store.each(function(record) {
record.set('ParentName', record.get('Parent') && record.get('Parent').Name || '-- Unparented --');
});
store.group('ParentName');
}
I thought it was a bug with the SDK too, but per WS API documentation, Parent, unlike Owner, or Feature is not sortable.
So when I use groupField: 'Parent' the grid is empty, and response showed error:
Ext.data.JsonP.callback6({"QueryResult": {..., "Errors": ["Cannot sort using attribute Parent"]
It is trying to sort by Parent, but Parent attribute is not sortable. So the SDK ran into a WS API limitation.
On a side note, I did not use groupBy, instead I used groupField on the store (in this example I grouped by Kanban field) :
var myStore = Ext.create('Rally.data.WsapiDataStore',{
model: 'UserStory',
groupField: 'c_MyKB',
//...
});
And then used features: [{ftype:'grouping'}] in the grid.
this._myGrid = Ext.create('Ext.grid.Panel', {
store: myStore,
features: [{ftype:'grouping'}],
//...

KendoUI pagination throws exception and doesn't show page information

I'm trying to get a KendoUI grid working with server side paging. So far I've managed to get the grid reading data from the remote datasource and correctly sending paging/filtering information to an MVC controller action
This is working fine, however, I don't see the paging controls for the grid at all.
I've tried adding pageable: true to the setup of the grid, and although this does display the pager control, it doesn't show any pages/totals and throws a JS object does not support this property or method when I try and change the page using the next/prev page buttons. The method it's looking for is 'slice' - I'm going to have a look at the non-minified kendo src but in the meantime I thought I'd post here
The action looks like this:
public ActionResult _Index(int? pageSize, int? skip, string filter = "")
{
// Code that gets the data
var data = ... (some Linq->Entities queries)
var total = ... (total count of all the entities)
return Json(new { total, data });
}
I'm correctly returning the total, and I've checked the JSON and it matches what I'm expecting (and what the grid should be expecting)
The grid setup is this:
$(document).ready(function () {
var grid = $("#itemList").kendoGrid({
toolbar: kendo.template($("#template").html()),
columns: ["Manufacturer", "Model", "Price", "Tags"],
dataSource: {
transport: {
read: {
url: "catalogadmin/_index",
dataType: "json",
type: "POST",
data: {
filter: ""
}
},
},
schema: {
data: "data", // records are returned in the "data" field of the response
total: "total" // total number of records is in the "total" field of the response
},
pageSize: 2,
serverPaging: true
},
pageable: true
});
I set the pageSize to 2 to test paging (as I only have 4 items in the DB at the mo)
JSON is:
{"total":4,"data":[{"Id":6,"Manufacturer":"hello","Model":";lmqw;lemwqe","Price":4.00,"ShortDescription":"world","Tags":[],"Used":false}]}
I don't think that's the issue though - it seems like you need to set pageable: true to get paging working - but I don't think the paging even works with client side data, I'm just going to check now
Edit: I've checked and client-side paging doesn't work either. I get an 'Unable to get property toLowerCase of undefined or null reference' when trying to page. The pager looks like the server side page, no data, no page numbers, no totals.
I'm thinking Kendo isn't quite registered right - I've got the very latest version (just downloaded it now) but no cigar...
Sorted - not sure why but when I installed KendoUI using Teleriks 'convert to Kendo UI project' it registered both the kendo.all.min.js file and also the mvc/dataviz ones.
I removed the extra script references and it's all working now!

Rally rallyaddnew with Portfolio Items

I have been trying to use a rallyaddnew to add Features and Rollups, which will then be rendered in a grid/cardboard. I got it to work and display, but I cannot customize the text to say create a new "Feature" or "Rollup", rather it says create a new "PortfolioItem/Feature" and "PortfolioItem/Rollup"
{
xtype: 'rallyaddnew',
recordTypes: ['PortfolioItem/Feature', 'PortfolioItem/Rollup'],
listeners: {
recordAdd: function() {
//
},
beforeRecordAdd: function() {
//
}
}
I couldn't find anything in the SDK on how to customize this.
This is a defect. It should be using the display name of the type instead of its type path. I'll file a defect for this. FYI there is also an existing defect around PI types and adding with details that has been fixed but has not been released in an SDK version yet.

Setting card owner 2.0p5

I am updating my custom kanban boards, and running into an issue with the newer API. This worked in 2.0p2, but not working in 5.
I have some code that is trying to set the current card to the current user. This is on the method beforecarddroppedsave.
card.record.set('Owner', con.context.user);
I can set other fields, that seems ok, but when trying to save the User, it isnt working. I have tried just setting the name to the owner, and that doesnt work either.
I looked in the documentation, but cant seem to find it yet, any help would be much appreciated!!
Please try the current App SDK 2.0rc1. This code should set the Owner on the card when the car is moved from one column to another:
var cardBoardConfig = {
xtype: 'rallycardboard',
types: ['Defect', 'User Story'],
attribute: 'ScheduleState',
storeConfig: {
filters: [this.iterationCombobox.getQueryFromSelected()]
},
listeners: {
beforecarddroppedsave: this._onMove,
scope: this
}
};
//..........
_onMove: function(cardboard, card){
var con = Rally.environment.getContext();
card.record.set('Owner', con.context.user);
console.log('ok');
},