Dynamics AX 2012 View Ignores Order By - view

I have a very simple view in AX 2012. It has one data source, and returns only one row from that table. The view has an Order By DESC specified on the same field that is being returned. There is no Group By clause.
It returns about the first 2/3 of the records in alphabetical order, then the last 2/3 also in alphabetical order, but starting over at A.
The results look something like this:
Apple,Banana,Cherry,Fig,Pear,Plum,Squash,Yam,Apricot,Blueberry,Zucchini
Tried Synchronize, Compile, CIL compile already. Tried dumping the data source and starting over. Pretty much out of ideas.
Jan: here is the View from SQL. Looks like even after I synchronize, the ORDER BY is left out.
USE [MicrosoftDynamicsAX]
GO
/****** Object: View [dbo].[MENUSVIEW] Script Date: 03/28/2014 09:57:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[MENUSVIEW] AS SELECT T1.TRANSACTIONNAME AS TRANSACTIONNAME,T1.PARTITION AS PARTITION,T1.RECID AS RECID FROM TRANSACTIONS T1
GO

No idea why this was necessary, and would still like to understand, but here is the workaround I used, by adding it to my form's datasource.
public void init()
{
super();
//manually sort the view, because the built in sort does not work
ScanWorkX_MenusPickerView_ds.query().dataSourceNo(1).sortClear();
ScanWorkX_MenusPickerView_ds.query().dataSourceNo(1).addSortField(fieldNum(MenusView,
TransactionName), SortOrder::Ascending);
}

The MSDN documentation on View Basics notes this:
Do not specify a field in the Order By element. A view cannot use the field information in the Order By element.
Which is very odd, considering there are vanilla views which have fields in the Order By element. An example is AssetInsurance.

Related

SSRS Static fields in groups

Good afternoon!
I have created a report with the wizard to create a matrix that is grouped and has drill down rows. I have added filters to the rows and columns and it works great! I then copied that matrix and modified the filters, so I had two matrixes.
But what I really wanted was those two rows in the same matrix, just in different row groups. So I added another group, using the adjacent below option, and then added all the child groupings. However, when I run the report it shows the values for the first row of the drill down data.
When I look at the groupings I can see the one I did manually has a 'Static' field in each row grouping but the ones that the wizard did (with the red ?), they don't have that "extra" row:
What do I need to change or how do I need to add my groups so that I don't get that "static" row and not show the data? I have the visibility set to 'Hidden' and the toggle set up for the prior grouping set data.
Assuming a few things....
the data comes from a single dataset
You are differentiating between Property and Violent crimes by filtering on a column, I'll call it IncidentGroup for the sake of illustration..
I've understood your question ! :)
Get to the point where you had just a single tablix filtered to show 'Property crime'.
Now remove or edit that filter so it shows all the data you need in the report.
Finally, right click on your Matrix1_IncidentCategory row and add a parent group, choose IncidentGroup (or whatever the column is actually called) and check the box to add a group header.
That should be it, there is no need for a second tablix.
Without knowing how you are filtering currently it's hard to give a complete answer but this should get you close, if not all the way there.
If this doesn't work for whatever reason, please post sample data from your dataset output and your current filters.

Best practice for single-valued result in SSRS 2012

I'm new to Reporting Services and using SQL Server Data Tools (Visual Studio 2012). I want to add an item that will display a single value - in this case, the result of a stored procedure call. The value would probably be displayed in the report header.
I've looked at the Tablix data parts that can be added to the report: table, list, and matrix. Not sure which of them, if any, would be appropriate. I could add a parameter item, but it seems that these function as user input choices.
I also looked at a read-only text box, but don't see how to populate it with a query result.
What is the accepted method of adding a single-value result to a report?
If this is to be displayed in the page header, your only option is a textbox; you can't add tablix type parts to page headers/footers.
The textbox expression would be something like:
=First(Fields!MyValue.Value, "DataSet1")
By using an aggregate expression like this you can make sure only one value is returned (even though you might always have only one) and you can also specify the aggregate's Scope; in this case the DataSet you want to query.
If this was going in the report body I would still recommend the same approach, though I wouldn't go so far as to call it best practise, any would work so it's really personal taste.
However, if you had multiple fields returned by the SP but still only one row, in that case I would recommend a table style tablix with one header-level row; easiest to maintain and layout.

SSRS Detail members can only contain static inner members

I am developing an RDL in SSRS 2008 and am trying to move a subreport table directly into a main report so that I instead run this subreport in the same stored proc as my main report.
However, I'm having trouble hooking this up. I got the stored procedure to run successfully. But now when I try to copy this table into the main report I get the following error:
[rsInvalidDetailDataGrouping] The tablix 'table1' has a detail member with inner members. Detail members can only contain static inner members.
Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate, the specified dataset scope
How can I do this?
I have tried moving the table into the group level and deleting the details grouping. I have removed sorting elements, etc. But the only way I got this error to disappear is to delete all of the groupings for this table and all textbox values.
If these are being returned from the same SP, then you should only have one Detail group (and one tablix).
The detail group (on your outer tablix) will be repeated once for each row returned by your dataset. A tablix contained within that row for the same dataset doesn't make sense: what would it repeat?
It sounds like you need to combine your two tablixes into one, not nest one in the other.
The easiest approach is probably to add a group to the parent tablix which will take the place of the former detail group. It will probably group by whatever field you joined to your old subreport dataset (or something similar.)
Then put your old subreport fields in the detail rows.
I was getting this error when building a report in VS2015 SSRS14.
A restart of Visual studio cleared the error.
In my case, a simple table report, Tablix4 was giving an error. This is because Tablix1 had a Rectangle as a child, and the Rectangle had Tablix4 as a child. Replacing Tablix1 with Tablix4 solved the problem.
<Tablix Name="Tablix1">
<TablixBody>
<TablixColumns>
<TablixColumn>
<Width>16.51cm</Width>
</TablixColumn>
</TablixColumns>
<TablixRows>
<TablixRow>
<Height>2.38745cm</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Rectangle Name="Rectangle1">
<ReportItems>
<Tablix Name="Tablix4">

VB6 and data-bound MSHFlexGrid, moving and populating columns

I'm working on a VB6 program that connects to a SQL Server 2008 R2 database. In the past I have always used the MSFlexGrid control and populated it manually. Now, however, the guy who is paying me for this wants me to use data-bound grids instead, which forces me to use the MSHFlexGrid control because I'm using ADO and not DAO. So, I have two questions...
First, how would I move a column in a MSHFlexGrid? For example, if I wanted the third column to appear as the sixth column in the grid, is there a simple single line of code that would do that?
Second, believe it or not, I've never had to do anything in a grid other than display the data, as is, from a recordset. Now, however, I have a recordset with some fields that contain just ID numbers that refer to records in other files - for example, a field containing an ID number referring to a record in the Customers table, instead of the field containing the customer's name. What is the easiest way to, instead of having a column showing customer ID numbers from the recordset, having that column show customer names? I thought I read somewhere that there's a way to embed a sql command in a MSHFlexGrid column, but if there is I wouldn't know how to do it. Is this possible, or is there a simpler way to do it?
TIA,
Kevin
The column order would typically be handled by your SELECT statement.
Say you have a Pies table that has a FruitID foreign key related to the FruitID in a Fruits table:
SELECT PieID AS ID, Pie, Fruit FROM Pies LEFT OUTER JOIN Fruits
ON Pies.FruitID = Fruits.FruitID
This returns 3 items: ID, Pie, and Fruit in that order.
Moving columns after the query/display operation is rarely used, but yes ColPosition can be used for that.
Wow! VB6.... Back to the future! :-)
You can move Columns using the ColPosition Property.
This article shows how you could setup the grid to display hierarchical data.
If you just want to display the customer name on the same line as the main data then that is doable as well by just creating the proper SQL for your data source. For that matter you can control the column order the same way as well.
Now, how about considering upgrading to .Net? Just kidding..... No, I'm not. OK. I am, maybe. :-)

How to Sort Data Table like FogBugz Cases Table

Anyone ever see how fogbugz sorts their tables? When you click to sort the column, they actually break the table up into many small tables that have each category of info.
Wondering if anyone knows how they do this?
Looking to implement this feature.
If you take a look through the cases page, and sort you can see what I mean.
Any help would be AWESOME!
Still Haven't figured this one out.
EDIT: #Peter, I don't want to postback and recreate a table every time the header title is clicked for a sort. I also want to know if their is a generic solution for this. If I click on the header to sort, by the way of javascript, it seperates the "one" table into many and I want to know if their is any generic solution for this because its just a MUCH better way of viewing a sorted Table.
EDIT: I do need a javascript sorter, but if you look right down at the implementation of fogbugz, it produces a different result...
Yup, Rich got it (I coded this feature into FogBugz a long while back).
If you have to do this on the client you have no choice but to sort the data, iterate through it generating table row after table row, and every time you hit a new sort value you create a new thead w/ the appropriate information.
To be honest it would be a pretty cool modification to this jQuery plugin: http://tablesorter.com/docs/ and you'd be able to leverage a lot of their work. If you're going to put in the time and create a general solution, might as well make it accessible to the community.
Without knowing specifically how Fog Creek accomplishes this, the way that I would do it is to output a table header, then iterate through the list, outputting a footer and a new header each time the group value changed.
Not sure what answer do you expect. SQL query for this would simply use ordering on selected column, and UI would start new table each time this value changes.
Here is screenshot of FogBugz with this sorting, after clicking on Priority column.
http://img297.imageshack.us/img297/6974/76755363ee3.png
Of course, starting new table doesn't make sense for every column (title, case #).
Edit: If I understand correctly, you're looking for a way how to do this in a browser without loading new page. If this is the case, I would suggest at least some server-side support, which would return your data in correct order, and properly structured for subtables (in xml/json/whatever you use). Your javascript will use this data to recreate tables. I am sure others with more web-ui experience will provide you with better answers.
I've used the Sortable Tables script from Kryogenix with some good results.
I don't know if it is relevant, but we store the results of a query in a temporary table in SQL, and then reference current-row-less-one to see if a Category has changed, and indicate this in the resulset.
In some instances we "indicate" this with a column containing
<tr><td colspan=999>Category Heading</td></tr>
so that the web page can just "inject" that into the table it is building.
SELECT Col1, Col2, ...,
[CATEGORY] = CASE WHEN T1.CategoryCol <> COALESCE(T2.CategoryCol, '')
THEN '<tr><td colspan=999>' + T1.CategoryCol + '</td></tr>'
ELSE ''
END
FROM #MyTempTable AS T1
LEFT OUTER JOIN #MyTempTable AS T2
ON T2.ID = T1.ID - 1

Resources