I am using the Rally SDK1.33 as in the end I need to display information using the LoginKey outside of Rally. I am trying to query information on PortfolioItem, but it looks like no results are being returned. - However if I put the query in the through the webservice doc pages, I get a result.
Using the following link (replacing 123456789 with a real ObjectID for a PortfolioItem and the workspace 987654321 with a real workspace) I get back the PortfolioItem object:
https://rally1.rallydev.com/slm/webservice/1.43/portfolioitem.js?workspace=https://rally1.rallydev.com/slm/webservice/1.43/workspace/987654321&query=(ObjectID%20%3D%20123456789)&fetch=true&start=1&pagesize=20
However if I try to query it from code, I get back the query results without any results and without any errors (again - using a real PortfolioItem ObjectID instead of the 123456789).
ExternalPortfolio
<!--App information-->
<meta name="Name" content="App: ExternalPortfolio"/>
<meta name="Version" content="1.0"/>
<meta name="Vendor" content=""/>
<!--Include SDK-->
<script type="text/javascript" src="https://rally1.rallydev.com/apps/1.33/sdk.js?debug=true&apiVersion=1.43"></script>
<script type="text/javascript">
function onLoad() {
rallyDataSource = new rally.sdk.data.RallyDataSource('__WORKSPACE_OID__',
'__PROJECT_OID__',
'__PROJECT_SCOPING_UP__',
'__PROJECT_SCOPING_DOWN__');
var objectId = 123456789;
var queryConfig = {
type: 'PortfolioItem',
key: 'portfolio',
fetch: 'FormattedID,Name',
query: '(ObjectID = ' + objectId +')'
};
rallyDataSource.findAll(queryConfig, showPortfolio, errorCallBack);
function showPortfolio(results) {
console.log(results);
}
function errorCallBack(response) {
console.log('Got problems!')
console.log(response.Errors);
console.log(response.Warnings);
}
}
rally.addOnLoad(onLoad);
</script>
<style type="text/css">
.externalPortfolio {
/* Add app styles here */
}
</style>
I have created a number of reports on Stories and Defects (most all running outside of Rally), but never for a PortfolioItem. - Am I missing something here? Or is there a severe bug with the v1.xx SDK or v1.x API in handling portfolio items?
This might not be the issue you're encountering, but if you're running outside Rally, try setting both the Workspace OID and Project OID:
rallyDataSource = new rally.sdk.data.RallyDataSource(
'12345678910',
'12345678911',
'__PROJECT_SCOPING_UP__',
'__PROJECT_SCOPING_DOWN__');
When I initially ran your example using Workspace OID only, I found that like you I was not receiving any results, and no errors were returned. However, examining the generated query URL in Chrome's network console:
https://rally1.rallydev.com/slm/webservice/1.43/adhoc.js?_method=POST&adHocQuery={"portfolio":"/portfolioitem?query=(ObjectID = \"152345647\")&pagesize=200&fetch=FormattedID,Name&workspace=/workspace/12345678910&project=${/user/userprofile/defaultProject}&projectScopeUp=false&projectScopeDown=true"}&jsonp=dojo.io.script.jsonp_dojoIoScript1._jsonpCallback
You can see that the User's default project is being passed as the Project parameter. However the PI with that specific ObjectID was in a different Workspace. As an outcome, I was receiving the following error:
{
portfolio: {
_rallyAPIMajor: "1",
_rallyAPIMinor: "43",
Errors: [
"The specified project must be in the specified workspace. Project OID=12345678921 is in Workspace OID=1234569840 and the specified Workspace is OID=12345678910."
],
Warnings: [ ],
_ref: "/portfolioitem?query=(ObjectID = "152345647")&pagesize=200&fetch=FormattedID,Name&workspace=/workspace/12345678910&project=/project/12345678921&projectScopeUp=false&projectScopeDown=true",
TotalResultCount: 0,
StartIndex: 0,
PageSize: 0,
Results: [ ]
}
}
Once I included the Project OID in the new-up of rallyDataSource instead of the hangman, I obtained the expected result in the console:
Object {errors: Array[0], warnings: Array[0], portfolio: Array[1]}
errors: Array[0]
portfolio: Array[1]
0: Object
DirectChildrenCount: 0
FormattedID: "F10"
Name: "PI Feature 10"
_objectVersion: "7"
_rallyAPIMajor: "1"
_rallyAPIMinor: "43"
_ref: "https://rally1.rallydev.com/slm/webservice/1.43/portfolioitem/feature/152345647.js"
_refObjectName: "PI Feature 10"
_type: "PortfolioItem/Feature"
__proto__: Object
length: 1
__proto__: Array[0]
warnings: Array[0]
__proto__: Object
Related
I have a MEAN-Stack setup in which i have Devices and Servicecases saved in the MongoDB-Database.
Devices can be the content of a Servicecase
If a new Case should be created, my Frontend will deliver the following form data:
content: [
{
"device": 012345678909876,
"errorDesc": "lorem"
},
{
"device": 012345678909876,
"errorDesc": "ipsum"
}
]
There could be a device document with the submitted device number in the Database. If yes, the received doc should be populated with its ObjectId to look like this:
content: [
{
device: { type: Schema.Types.ObjectId, ref: 'Device' },
errorDesc: String
},
...
]
If not, it should stay as it is
I could iterate through each device of the array and use the findOne() query and, if a doc was found, replace it, but is there a more efficient way to use the populate() transformation?
I have been struggling with this for a couple of days now and I felt like I should reach out. This might be very simple but I am not from a programming background and I haven't found any resources to solve this so far.
Basically, I want to parameterize a SQL query that is running for BigQuery within Google APp Script, it takes a variable from a user from a Google From they have submitted and I wanted to ensure that this won't be injectable by parameterizing the query, however, I got the following error that I could not fix:
GoogleJsonResponseException: API call to bigquery.jobs.query failed with error: Query parameter 'account_name' not found at [1:90]
Here is how I run the query:
//Query
const sqlQuery = 'SELECT district FROM `table` WHERE account_name = #account_name AND ent_theatre=("X") LIMIT 1;'
const request = {
query: sqlQuery,
params: { account_name: queryvar },
useLegacySql: false,
};
// Run Query
var queryResult = BigQuery.Jobs.query(request,projectID);
I have created the query based on Google's documentation
Your syntax for request object is not correct. The right syntax for the BigQuery.Jobs.query Request is like below:
const request = {
query: sqlQuery,
queryParameters: [
{
name: "account_name",
parameterType: { type: "STRING" },
parameterValue: { value: queryvar }
}
],
useLegacySql: false,
};
For more detail about QueryRequest Object refer to this link.
As a beginner I have few questions. I am using the Get request, which would populate json below.
https://reqres.in/api/users
{
"total": 12,
"total_pages": 4,
"data": [{
"id": 1,
"first_name": "George",
"last_name": "Bluth",
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/calebogden/128.jpg"
}]
}
for the 2 tests below while the 1st one passes the 2nd test fails with the message:
AssertionError: expected false to be truthy
//Verify Page number total is 12
var jsonData = JSON.parse(responseBody);
tests["Checking total page number-Manual"] = jsonData.total === 12;
//verify is exists and is 1
var jsonData = JSON.parse(responseBody);
tests["Checking ID exists and is 1"] = jsonData.id === 1;
Question 1:
A github post that I found says there may be an error and suggests to use
the new pm.* equivalent instead. However I do not see any difference between the 1st and the 2nd. So why does the 2nd test fail?
Question 2:
Is it possible to write test to verify that for ID:1 the firstname is George?
Thanks in advance for your time.
The reason that your 2nd test fails is because data is an array and in this case you must access the first element. You would want to do something like this (new syntax):
pm.test("Verify id is equal to 1", function() {
var jsonData = pm.response.json();
pm.expect(jsonData.data[0].id).to.equal(1);
});
Similarly for testing first name is George:
pm.test("Verify id is equal to 1", function() {
var jsonData = pm.response.json();
pm.expect(jsonData.data[0].first_name).to.equal("George");
});
If you always expect it to only be a single element in the array then you're safe to use index 0 i.e. data[0]. However if you expect there to be more elements in the data array then you would have to iterate through them to look for the correct element.
Here's a good reference for the API:
https://learning.getpostman.com/docs/postman/scripts/postman_sandbox_api_reference/
I have this jquery code:
$("#tf_zoom").live("click", function () {
var n = $(".tf_thumbs").find("img").attr("src");
var modelid = n.substr(43);
$.post("models/get_gallery", {
"modelid": modelid
}, function (data) {
var imagespathes = $(data).map(function (key, url) {
return ({
href: '<?php echo base_url();?>assets/uploads/files/' + url
});
});
console.log(imagespathes);
$.fancybox.open(imagespathes);
}, "json");
});
and this is my html:
<div id="tf_thumbs" class="tf_thumbs">
<span id="tf_zoom" class="tf_zoom"></span>
<img id="dynam" src="<?php echo base_url();?>assets/uploads/files/<?php echo $firstthumb;?>" alt="Thumb1"/>
</div>
Okay, now my problem is that this code is not functioning on IE 10 and surprisingly it's working like a charm on IE 9, IE 8, IE 7 besides FF and Google Chrome
I read many things about this issue but nothing worked for me.
So, is there any solution for it.
your help is really appreciated.
Update 1 : I am using jquery version 1.7
Perhaps this hint will help you:
I have noticed that .map( $("select").get(0).options ) will not work in IE10 but .map( $("select:first >option") ) will. This is because in ie10 .options returns a select node with an iteration of options.
So see what data is returning in IE10, perhaps it too is not an array. And if so perhaps you can do something like $(new Array(data)).map(... which will satisfy all browsers
You should be using static map function for this:
$.map(data, function(obj, index){...})
See documentation here.
// If data looks like this: [{ url: 'TestUrl' }]
// This should work:
var imagespathes = $.map(data, function(element){
return { href: '<?php echo base_url();?>assets/uploads/files/' + element.url };
});
May I know if it is possible to put pictures or images into the rows of DataTables (http://datatables.net/) and how does one goes in doing it?
yes, simple way (Jquery Datatable)
<script>
$(document).ready(function () {
$('#example').dataTable({
"processing": true, // control the processing indicator.
"serverSide": true, // recommended to use serverSide when data is more than 10000 rows for performance reasons
"info": true, // control table information display field
"stateSave": true, //restore table state on page reload,
"lengthMenu": [[10, 20, 50, -1], [10, 20, 50, "All"]], // use the first inner array as the page length values and the second inner array as the displayed options
"ajax":{
"url": "#string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Content("~"))/Home/AjaxGetJsonData",
"type": "GET"
},
"columns": [
{ "data": "Name", "orderable" : true },
{ "data": "Age", "orderable": false },
{ "data": "DoB", "orderable": true },
{
"render": function (data, type, JsonResultRow, meta) {
return '<img src="Content/Images/'+JsonResultRow.ImageSrcDB+'">';
}
}
],
"order": [[0, "asc"]]
});
});
</script>
[edit: note that the following code and explanation uses a previous DataTables API (1.9 and below?); it translates easily into the current API (in most cases, just ditch the Hungarian notation ("fnRowCallback" just becomes "rowCallback" for example) but I have not done so yet. The backwards compatibility is still in place I believe, but you should look for the newer conventions where possible]
Original reply follows:
What Daniel says is true, but doesn't necessarily say how it's done. And there are many ways. Here are the main ones:
1) The data source (server or otherwise) provides a complete image tag as part of the data set. Don't forget to escape any characters that need escaping for valid JSON
2) The data source provides one or more fields with the information required. For example, a field called "image link" just has the Images/PictureName.png part. Then in fnRowCallback you use this data to create an image tag.
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var imgLink = aData['imageLink']; // if your JSON is 3D
// var imgLink = aData[4]; // where 4 is the zero-origin column for 2D
var imgTag = '<img src="' + imgLink + '"/>';
$('td:eq(4)', nRow).html(imgTag); // where 4 is the zero-origin visible column in the HTML
return nRow;
}
3) Similar to above, but instead of adding a whole tag, you just update a class that has the image as a background. You would do this for images that are repeated elements rather than one-off or unique pieces of data.
You mean an image inside a column of the table?
Yes, just place an html image tag
like this
<img src="Images/PictureName.png">
instead of putting data (some string) into a column just put the above html tag....
Asp.net core DataTables
The following code retrieve the image from a folder in WWWroot and the path in the DB field ImagePath
{
"data": "ImagePath",
"render": function (data) {
return '<img src="' + data + '" class="avatar" width="50" height="50"/>';
}
}
In case the Name of the picturefile is put together out of one or more informations in the table, like in my case:
src="/images/' + Nummer + Belegnummer + '.jpg"
you can make it that way:
var table = $('#Table').DataTable({
columnDefs: [
{
targets: 0,
render: getImg
}
]
});
function getImg(data, row, full) {
var Nummer = full[1];
var Belegnummer = full[4];
return '<img src="/images/' + Nummer + Belegnummer + '.jpg"/>';}
The picture is in the first column, so Targets = 0 and gets the Information from the same row.
It is necessary to add the parameters data and row.
It is not necessary to outsource it into a seperate function, here getImg, but it makes it easier to debug.