Archive

Archive for the ‘SSRS Reports’ Category

SSRS Tip: Prevent report execution through controller – Dynamics Ax 2012

September 25, 2013 Leave a comment

What a user might hate to see is a blank report. No matter where the mistake lies the earlier we react the happier the user is. Here today i’m sharing a tip on how you could stop/warn/show a info after the report execution is initiated  after the user clicks the “Ok” button in the dialog.

In the example discussed here, the idea is to check preemptively if a query will return a record or not. If no then the report aborts execution.

To implement this, open the controller of your report or create one.

On the controller class, override the method “preRunValidate”

Place the code as shown here. This method is invoked after the user clicks the “Ok” button and before the report is executed. Do not block the super call in this method as it does few other important validations. This method can return an error/warning/info. If it is a warning or error the report aborts further execution.

protected container preRunValidate()
{
    container   validateResult = super();
    Query       firstQuery;
    int         recordcount;

    firstQuery          = this.getFirstQuery();
    custStatementCount  = QueryRun::getQueryRowCount(firstQuery, 6);
    if (custStatementCount > 5)
    {
        validateResult = [SrsReportPreRunState::Error, "No valid records found for the specified range"];
    }

    return validateResult;
}

Standard recommends the method to be used for validating if the report returns a large amount of data.For reference see \Classes\CustAgingReportController\preRunValidate\
For more tips and learning about SSRS – AX 2012 order the book Dynamics AX 2012 Reporting Cookbook authored by me.

7720EN_MockupCover_Cookbook

Advertisements

SSRS Tip: Printing Row headers in every page – Dynamics Ax 2012

September 23, 2013 2 comments

This post today will discuss how to print row headers in every page for tablix.

When your table has a header

When using table type tablix with headers as seen in the below image, right click on the Tablix properties and select “Repeat header rows on each page” (If you use a matrix control please check the same for “Repeat header columns on each page”)

RepeatHeader

When you use a static tablix member in Row or Column.

If you don’t realize what a static tablix member, select a table and insert a row using the option “Outside Group – Above” or simply Insert Row -> Above if you don’t have any groupings. Now open the Group mode window (if not open, click the grouping icon from your report tool bar grouping_windo) and then click Advanced mode. The system will show up static members in a table. These are members that are calculated once and are rendered in one or multiple pages. These controls can also be used like headers.

Coming back, Once you have identified the static tablix member you want to repeat, On the property of the tablix member set “RepeatOnNewPage” to True. (If this doesn’t work outright, try setting the property “KeepWithGroup”  to “After”)

2013-09-20_1954

For more tips and learning about SSRS – AX 2012 order the book Dynamics AX 2012 Reporting Cookbook authored by me.

7720EN_MockupCover_Cookbook

SSRS Tip: Using invisible parameters in contracts – Dynamics AX 2012

September 18, 2013 3 comments

There can be cases where you wanted a contract in the attribute but do not want the UI builder to expose it to the user. The reporting framework in AX provides a very easy way to incorporate this.

Open the parm method in the contract that you don’t want to expose. Add the attribute shown here along with other attributes. This attribute when found in the parm method will automatically prevent the UI builder from adding this to the dialog.

[DataMemberAttribute, SysOperationControlVisibilityAttribute(false)]
public LogisticsAddressing parmAddress(LogisticsAddressing _address = companyAddress)
{
companyAddress = _address;
return companyAddress;
}

This feature comes as a part of the BOF, see here http://j.mp/185ufd2

Update: Apologize for the wrong statement here. The only way to make a parameter visible when using the contract with reporting framework is to specify it in the design. This is because the contract class \Classes\SrsReportRdpDataContractInfo\buildMemberAndNestedObjectMap – 29 ignores this attribute and reads the design RDL (created using your VS) to decide if a parameter must be visible in the contract. So to hide your parameter open the parameters node in Visual studio and then set the visibility property to hidden.Also a point to understand is that the VS design overrides any specifications at the contract level for properties like  LableHelp, Visibility, grouping, HelpText, value type (multivalue) etc. (Ref: \Classes\SrsReportRdpDataContractInfo\fillReportDesignProperties). Thanks to a AXForum member who pointed this out.

2013-09-30_1910

For more tips and learning about SSRS – AX 2012 order the book Dynamics AX 2012 Reporting Cookbook authored by me.

7720EN_MockupCover_Cookbook

SSRS Tip: Using labels for dynamic texts in SSRS reports – Dynamics Ax 2012

September 16, 2013 9 comments

Dynamic text in the reports makes them more readable and meaningful. In this article we will see how we can use labels from  AX to construct your dynamic text. The string format option comes handy to help us do this.

Here is how you must specify a string text with labels in it.

Open the report control properties and on the property “Value”, select the expression option and place your text in the format seen here.

=System.String.Format(“This is a label id converted at run time {0}”, Lables!@SYS1560);

You can also use report or data base fields like Fields!CustTable.Value to construct your Dynamic text.

For more tips and learning about SSRS – AX 2012 order the book Dynamics AX 2012 Reporting Cookbook authored by me.

7720EN_MockupCover_Cookbook

SSRS tip: Take care that VS and AX client are in the same layer for SSRS – Dynamics AX 2012

September 5, 2013 14 comments

Some times when you use configuration files to start your AX client like this in the image and also work on visual studio, make sure your default client configuration is pointing to the same layer as in the configuration file.

2013-08-30_1528

This is because the Visual studio opens in the layer that is specified in the default settings in AX Client Configuration window. Though your AX client is on VAR layer if your default client configuration setting is pointing to the USR layer then the visual studio reporting project gets saved to the USR layer. You end up in deleting and reimporting the entire project. So make sure to verify the layer setup before you start working on reporting projects.

To setup the default layer configuration, 

Open the run window and type axclicfg

In the window that opens create a new configuration or on the existing configuration go to the Developer tab and verify the layer information including the license

2013-08-30_1535

For more tips and learning about SSRS – AX 2012 order the book Dynamics AX 2012 Reporting Cookbook authored by me.

7720EN_MockupCover_Cookbook