Report AX 2012
Link
Localization
Paper format
Margin
Alignment
Alignment RTL - Report RTL
Alignment RTL - Report RTL - Textbox RTL
Alignment RTL - Report LTR - Textbox RTL
Alignment RTL 2 String
Code to put the comma before
Label
Refresh DS - add parameters
Print Setup management
Use a textBox value in an expression
Image - Logo
Header and footer
Rows Group
x Rows in the grid
Sort with expression
BackGroundColor
BackGroundImage - Write on a image
Show copy - orig
CountRows -> Visible
Bold by code
Show range of the query
Code for debug
Create new report
Copy report in VS
Error in deploy
Key for the Visual Studio
Format
Example of expression
Deploy by command
BI SqlServer for Visual studio

Report AX 2012
General book AX 2012
General reporting
Functions
SSRS Report
Print management
Remark : Restart of Reporting services help if the added fields in the table of the query, because something refresh of DS is not enough. I chechek it !
Localization
(PrintMgmtReportFormat, populate : We don't need to add the report)

PrintMgmtDocType, method getDefaultReportFormat
            if (SysCountryRegionCode::isLegalEntityInCountryRegion([#isoIL]))
            {
                return ssrsReportStr(FreeTextInvoice, ReportIL);
            }
//It is enought, we we open the Accounts receivable>Setup>Form Setup + Button Print Management,
//in the list of the report for free text invoice we can see the ReportIL

Bug with the language HE that the report is not put on the right.
Solution open the rdl file. To open the RDL file, do Edit using designer on the report ReportIL 
and after CTRL- F -> Open of the rdl FILE.



Replace it with:
 


2. Look for:
 
     
 AND its pair:
 
   
and delete it.

Paper format
US Letter 	: 8.5  * 11   inches (216 mm * 279 mm)

A4 	  		: 8.27 * 11,7 inches (210 mm * 297 mm)

Convert pixels to cm,inch ... 
http://www.translatorscafe.com/cafe/units-converter/typography/calculator

Margin
Paper = 20 cm, Margin 0 -> in Hebrew it is cut on the left. -> solution add a right margin :0.5 cm -> in hebrew left margin on the left

Good for hebrew : Margin right = 0.5 cm -> in hebrew margin left = 0.5 cm

English : Tablix of 15 cm
XXXXXXXXXXXXXXXXXXXX  
TABLIXXXXXXXXXX
123456789012345
XXXXXXXXXXXXXXXXXXXX  

=> in hebrew the tablix is on the left
XXXXXXXXXXXXXXXXXXXX  
TABLIXXXXXXXXXX
543210987654321
XXXXXXXXXXXXXXXXXXXX  


Alignment
----------------STRING-------------------REAL-----------
			English		Hebrew		English		Hebrew
Default		Left		Left		Right		Right
General		Left		Left		Right		Right
Left		Left		Right		Left		Left
Right		Right		Left		Right		Right

Alignment
Link that explain the RTL language transformation
Spacing with RTL

Alignment RTL - Report RTL
//We can put RTL = true for all the report.
//RTL = true => there is no transformation for left to right for the hebrew for the position of the report.
It means that the position of the texbox doesn't move, but the textbox are not RTL !!!!!!!!!!!!!!! only the report is RTL!!!!!!
//What you see, it what you get.
Alignment
Alignment RTL - Report RTL - Textbox RTL
//We can put RTL = true for all the report, but the texbox are not RTL !
// If there is a text in hebrew that finish by .,:! -> there is a problem that the letter is a the biginning of the text 
// and not in the end.
Alignment
Alignment RTL - Report LTR - Textbox RTL
To avoid problem with the comma at the end of a line :
Alignment

Alignment RTL 2 String
//RTL on the textbox = true => there is no transformation for left to right for the hebrew.
ex :=  format(First(Fields!SalesBalance.Value, "DS"),"#,0.00")  + space(1) + First(Fields!SPLSymbol.Value, "DS")
Alignment

Code to put the comma before
//שלום, => To see ,שלום : but we don't need this code if we use Direction=RTL
//In the string it is written "שלום,", so we must put the last letter at the first place 
static public str  TxtRight(str _txt)
{
    str 200             txt2;
    int                 i;
    int                 pos = 0;
    str 1               letterBefore,lastLetter;

    pos = strScan(_txt,"\n",1,strLen(_txt));
    if (pos)
    {
        while (pos > 0)
        {
            letterBefore = substr(_txt,pos - 1,1);
            if (letterBefore    == "," ||
                letterBefore    == "." ||
                letterBefore    == "!")
                txt2   = txt2 + '\u2029' + letterBefore + '\u2029' + substr(_txt,1,pos - 2) + "\n";
            else
                txt2   = txt2 + substr(_txt,1,pos);

            _txt   = substr(_txt,pos + 1,strLen(_txt));

            pos    = strScan(_txt,"\n",1,strLen(_txt));
        }
        if (_txt)
        {
            lastLetter = substr(_txt,strLen(_txt),1);
            if (lastLetter    == "," ||
                lastLetter    == "." ||
                lastLetter    == "!")
                txt2        = txt2 + '\u2029' + lastLetter + '\u2029' + substr(_txt,1,strLen(_txt) - 1);
            else
                txt2        = txt2 + _txt;
        }
        return txt2;
    }
    else
    {
        lastLetter = substr(_txt,strLen(_txt),1);
        if (lastLetter    == "," ||
            lastLetter    == "." ||
            lastLetter    == "!")
            txt2        = txt2 + '\u2029' + lastLetter + '\u2029' + substr(_txt,1,strLen(_txt) - 1);
        else
            txt2        = txt2 + _txt;
        return txt2;
    }
}

Label
-If I create a new label, it is enougth to restart the reporting service.
we must restart the AOS To see the label in Reporting Services.
Or We can do an import of the label, and It seems to me that we don't need to restart the AOS

//Code '\u2029' prevent from inverse side of the string in hebrew
splCustInvoiceTmp.TxtComments[1] =  ":" + '\u2029' +  periodTxt + " " + '\u2029' + custInvLbl + '\u2029';

//Code to put the label in the good language

static str  invoiceTxt(CustInvoicetable _custInvoicetable, PrintCopyOriginal _printCopyOriginal)
{
    str             invoiceTxt;
    Label           label;
    CustInvoiceJour custInvoiceJour= _custInvoicetable.splCustInvoiceJour();
;
 
    if (!_custInvoicetable.InvoiceId)
    {
      invoiceTxt = literalStr("@SYS24608");
    }

    label = new Label(_custInvoicetable.LanguageId ? _custInvoicetable.LanguageId : infolog.language());

    return label.extractString(invoiceTxt);
}



Refresh DS - add parameters
When we add a fied in the table use in the DataSet we need to refresh the DataSet
to see the need field in the Table. The problem is that we we refresh the DS
the system add parameters that wasn't in the report before.
When we run the  report we have a message : The 'PurchPurchaseOrderDS_Location' parameter is missing a value\
So we need to allow the parmameter to be null.
1 - Rename the field to field_1
2 - Put the Allow Blank and Nullable to true
3 - Deploy
4 - Rename the field_1 to field
5 - Deploy

Notes : sometimes when we transfer a report from one environement to a second environement,
We have problems with parameters. 
Sometimes we need to delete the report in reporting services in the second environement.
ShortCut

Print Setup management
To use the new Report SPL each time that we print, the SPL report must be of type system in the table
PrintMgmtReportFormat
Mgmt
Populate
in a client it as a problem with the value true.
Populate


Use a textBox value in an expression
We can use a value of a text box in an other expression


Image - Logo
Sometimes we want that the image will be in a fix value to avoid
differences of logo between dev and prod. 


Header and footer
If we do visible="False" in the header of footer, the place used by the footer is keep.
So We cannot do invisible for the footer or the header

Rows Group




x Rows in the grid
// we can put x rows in the grid ex : LedgerTransStatementReport
// If there are 2 rows, the read the table and write the two rows


Sort with expression


BackGroundColor
//Line backGround


BackGroundImage - Write on a image
//We can write on a image if the image is the backGroudImage


Show copy - orig
//To print original or copy, test the instance.
=iif(Parameters!SalesFormLetterIsProforma.Value = "True", 
	 Labels!@SYS75939,
	 iif(Parameters!InstanceType.Value = "Copy", 
		 Labels!@SYS40266,  
		 Labels!@SYS5301))
		 
		 
In the controller : printSettingDetail.parmInstanceName.
protected void runPrintMgmt()
{
    CustInvoiceJour             custInvoiceJour;
    PrintMgmtPrintSettingDetail printSettingDetail;
    SRSPrintDestinationSettings SRSPrintDestinationSettings;
    if(!journalList || !journalList.first(custInvoiceTable))
    {
        throw error("@SYS26348");
    }

    do
    {
        custInvoiceJour = custInvoiceTable.splCustInvoiceJour();

        formLetterReport.loadPrintSettings(custInvoiceTable, custInvoiceTable, CustInvoiceTable.LanguageId);


        this.parmContract().parmPrintCopyOriginal(printCopyOriginal);
        printSettingDetail = new PrintMgmtPrintSettingDetail();


        printSettingDetail.parmReportFormatName("SPLCustInvoice.Report");

        printSettingDetail.parmType(printCopyOriginal ==PrintCopyOriginal::OriginalPrint ? PrintMgmtDocInstanceType::Original : PrintMgmtDocInstanceType::Copy);

        printSettingDetail.parmInstanceName(enum2str(printCopyOriginal ==PrintCopyOriginal::OriginalPrint ? PrintMgmtDocInstanceType::Original : PrintMgmtDocInstanceType::Copy));
        printSettingDetail.parmNumberOfCopies(1);
        SRSPrintDestinationSettings = new SRSPrintDestinationSettings();
        printSettingDetail.parmPrintJobSettings(SRSPrintDestinationSettings);
        printSettingDetail.parmPrintJobSettings().printMediumType(SRSPrintMediumType::Screen);
        formLetterReport.parmReportRun().loadSettingDetail(printSettingDetail);
        this.outputReports();
    }

CountRows -> Visible


Show range of the query


Code for debug
static void SPLRunHMIDP(Args _args)
{
        // call report objects
    SPLItemHMIOnhandController  controller = new SPLItemHMIOnhandController();
    SPLItemHMIOnhandDP dataProvider = new SPLItemHMIOnhandDP();
    SPLItemHMIOnhandContract contract = new SPLItemHMIOnhandContract();
    
    // fill contract parameters
    contract.parmPerDate(str2Date("31/08/2013",213));

    // call report query
    controller.parmReportName(ssrsReportStr(SPLItemHMIOnhand,Report));
    controller.prompt();

    // transfer contract to dp
    dataProvider.parmDataContract(contract);
    
    // transfer query to dp
    dataProvider.parmQuery(controller.SPLGetfirstQuery());
    
    // run processing
    dataProvider.processReport();
}

Create new report


Copy report in VS
//We can copy in VS the report, and by drag and drop, put it in the project



Error in deploy
Error	1	The "DeployToReportsServerTask" task failed unexpectedly.
System.IO.FileLoadException: Le chargement de cet assembly produirait un jeu accordé différent des autres instances. (Exception de HRESULT : 0x80131401)

//Solution  Add a variable in the computer variable.


Key for the Visual Studio
Control + -> : to move the textbox a little

Format
(=====Format excel========  ex #,0.00;   to keep 9 spaces write : ########0 : to check.
Format for a Real : number = 65565
#,0.00;			-> number : 65,565.00
#,0.00;(#,0.00) -> number : 65,565.00, if number = -65565 => (65,565.00)
#,0.00;-#,0.00;'' -> to check
int the expression : 
= format(Last(Fields!AmountCurDebitTotal.Value, "SPLBankTransferDS"),"#,0.00") + " " + Last(Fields!CurrencySymbol.Value)  > 65,565.00 $

// Format for date 


Bold by code
textbox, create place holder type markup html
"text to put  in bold "


Example of expression
//==========STRING========================
= iif(Fields!EnterpriseNumber.Value=space(0),space(0),Labels!@SYS77429)
=Fields!EnterpriseNumber.Value
=iif(First(Fields!InvoiceAmount.Value, "FreeTextInvoiceDS") >= 0, Labels!@SYS115505, Labels!@SPL2884)
=iif(Parameters!SalesFormLetterIsProforma.Value = "True", 
	Labels!@SYS75939,
	 iif(Parameters!InstanceType.Value = "Copy", 
		Labels!@SYS40266,  
		Labels!@SYS5301))
=Microsoft.Dynamics.Framework.Reports.DataMethodUtility.GetFullCompanyNameForUser(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value)
=IIF(First(Fields!OtherHolder.Value,"Details") = "No" and 
    (First(Fields!OperationType1.Value,"Details") = "DirectRouting" or first(Fields!OperationType1.Value,"Details") =  "StoringReconditioning") ,"X","")
//============REAL=========================
=Format(First(Fields!SPLTaxValue.Value,"FreeTextInvoiceHeaderFooterDS"),"0.00")
=Format(First(Fields!SPLTaxValue.Value,"FreeTextInvoiceHeaderFooterDS"),"#,0.00")
=iif(Sum(Fields!RevisedAmount.Value) = 0 , 0,
 Sum(Fields!LedgerAmount.Value) / Sum(Fields!RevisedAmount.Value) * 100)
=Microsoft.Dynamics.Framework.Reports.BuiltInMethods.ToDisplayStringAmount(Parameters!AX_RenderingCulture.Value, Sum(Fields!AmountDebit.Value), true)
=Microsoft.Dynamics.Framework.Reports.BuiltInMethods.ToDisplayStringAmount(Parameters!AX_RenderingCulture.Value, sum(Fields!SPLAmountUSD.Value), true)

CDec(0.03) -> 0 : cdec return a number without decimal

Sum(IIf(Fields!BankAName.Value = "Standard Chartered Bank"
	, Fields!Amount.Value
	, Nothing)
	, "DataSet1")

//=============DATE========================
= Microsoft.Dynamics.Framework.Reports.DataMethodUtility.ConvertUtcToAxUserTimeZoneForUser(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value, System.DateTime.UtcNow, "d",Parameters!AX_RenderingCulture.Value)
==> 3/9/2015
if we want format dd/mm/yyyy
= Microsoft.Dynamics.Framework.Reports.BuiltInMethods.ToDisplayStringDate(Parameters!AX_RenderingCulture.Value,
  Microsoft.Dynamics.Framework.Reports.DataMethodUtility.ConvertUtcToAxUserTimeZoneForUser(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value, System.DateTime.UtcNow, "d", Parameters!AX_RenderingCulture.Value), 
  "dd/MM/yyyy")

//Format date
= Microsoft.Dynamics.Framework.Reports.BuiltInMethods.ToDisplayStringDate(Parameters!AX_RenderingCulture.Value,Fields!FromDate.Value, "dd/MM/yyyy")
 
=iif(Fields!TaxCode.Value <> "", Space(0), Microsoft.Dynamics.Framework.Reports.BuiltInMethods.ToDisplayStringDate(Parameters!AX_RenderingCulture.Value,Fields!TransDate.Value, "d"))


=Replace(Replace(Labels!@GLS110895, "%1", Parameters!FromDate.Value), 
		"%2",
		Parameters!ToDate.Value) // @GLS110895 = "Statement for period from %1 to %2"
		
		=format(Parameters!FromDate.Value,Microsoft.Dynamics.Framework.Reports.DataMethodUtility.MapAXLanguageToCultureSupportedBySSRS(Parameters!AX_RenderingCulture.Value).DateTimeFormat.ShortDatePattern)& "-" & 
		format(Parameters!ToDate.Value,Microsoft.Dynamics.Framework.Reports.DataMethodUtility.MapAXLanguageToCultureSupportedBySSRS(Parameters!AX_RenderingCulture.Value).DateTimeFormat.ShortDatePattern)

//=============TIME========================
= Microsoft.Dynamics.Framework.Reports.DataMethodUtility.ConvertUtcToAxUserTimeZoneForUser(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value, System.DateTime.UtcNow, "t",Parameters!AX_RenderingCulture.Value)
==> 5:47 PM 
If we want format hh:mm:ss
= Microsoft.Dynamics.Framework.Reports.BuiltInMethods.ToDisplayStringDate(Parameters!AX_RenderingCulture.Value,
  Microsoft.Dynamics.Framework.Reports.DataMethodUtility.ConvertUtcToAxUserTimeZoneForUser(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value, System.DateTime.UtcNow, "t", Parameters!AX_RenderingCulture.Value),
  "hh:mm:ss") 

//Format time //put time or date time
= Microsoft.Dynamics.Framework.Reports.BuiltInMethods.ToDisplayStringDate(Parameters!AX_RenderingCulture.Value,Fields!time.Value, "hh:mm:ss") 

//=============PAGES========================
=System.String.Format(Labels!@SYS182566, "" & Globals!PageNumber & "", "" & Globals!TotalPages & "")  //Page {0:N} of {1:N}
=trim(Str(Globals!PageNumber)) + "/" + trim(str(Globals!TotalPages))

=CStr(Replace(Labels!@GLS222395,"%1", CStr(Globals!PageNumber - 1))) //to check. @GLS222395 = "Transferred from previous page %1"

page X of Y : 4 textbox
=Labels!@SYS5250 ; =Cstr(Globals!PageNumber) ; =Labels!@SYS26401 ; =Cstr(Globals!TotalPages)

// IT IS NOT GOOD -> 1 1 MITOKH
=System.String.Format("{0} {1} {2}", Globals!PageNumber, Labels!@SYS26401, Globals!TotalPages)

//=============VISIBILITY========================
=iif(First(Fields!PrintFreeTextInvoiceVATNum.Value, "SalesInvoiceHeaderFooterDS") ="No", True,False)


//Interresting expression :
=IIf(System.String.IsNullOrEmpty(Join(Parameters!BillingClassification.Label)), Join(Parameters!BillingClassification.Value, ", "), Join(Parameters!BillingClassification.Label, ", "))


Deploy by command
Open as administrator Microsoft Dynamics Management Shell
//(for all report)
Publish-AXReport -ReportName * 


BI SqlServer for Visual studio
To open a design of a report on VS, we need a BI composant of SqlServer.