• Microsoft Dynamics NAV Team Blog

    Labels in NAV2009 Report Design

    • 0 Comments

    When adding fields to a report, the caption is typically added automatically or with a bit of drag and drop from the DataSet in VS Report Layout. But if you want to add additional labels, for example Report Name in the header, then there are a few more steps you must follow.

    Of course, you can just add a new TextBox in VS Layout, and type in the value you want to show. This is simple but will not give you Multi Language. Using a label from the classic report design gives you Multi language, but is a bit more complicated. This is what you need to do:


    As usual, before you can use it in the layout you must add the label to the report sections, and then specify the caption you want to display. In this case, make sure to also specify a name in the DataSetFieldName-property of the label. For this example, let’s call it Report_Label.
    To get the label value (Caption) into the layout, you must first add it to the Table on the Body-part of the layout. Note: It must be part of the table, and not in a TextBox outside of the table. The name of the cell will default to the DataSetFieldName you specified (Report_Label). And the value must be =Fields!Report_Label.Value. You get this value automatically if you drag it from the Data Set into a detail-section of the table. The caption is only here to be available from the header part of the report, so you can set the Visible-property to No.

    Finally you can get the label from the table and add it to a header-section in the report layout: Add a new TextBox, then name it something unique, for example Report_Label1, and set Expression = =ReportItems!Report_Label.Value. Note that "Report_Label" refers to the cell you added above, not directly to the label on the sections.

    This picture shows the steps needed to get the label to show in the header:

    AddLabel

     

     

     

    Lars Lohndorf-Larsen (Lohndorf)

    Microsoft Dynamics UK

    Microsoft Customer Service and Support (CSS) EMEA

  • Microsoft Dynamics NAV Team Blog

    Join us at the Microsoft Dynamics NAV Sessions at Convergence in New Orleans

    • 0 Comments

    We're just two weeks away from Convergence 2009 in New Orleans from March 9-13. We have created more than 70 sessions and Hands on Labs in the Microsoft Dynamics NAV track. Many of the sessions and all Hands on Labs will be focused upon the newest release, Microsoft Dynamics NAV 2009. For the list of sessions see the session list on Convergence web site.

    You can familiarize yourself with the new RoleTailored User Experience, Web Services and Reporting capabilities. You can learn about the different application areas, such as Manufacturing, Distribution, Finance and Service Management.  There are also industry related sessions where you can hear how Microsoft Dynamics NAV is used in different industries.

    To register for Convergence 2009, or for more information, see the Convergence web site.

    -Eva Sachse

  • Microsoft Dynamics NAV Team Blog

    Cursor Types

    • 0 Comments

    One of the changes in Microsoft Dynamics NAV version 5, was to change from primarily making use of Fast-Forward cursor types to Dynamic cursors. The same change was implemented in version 4 from build 26410, which is Version 4, SP3 Update6(940718) + KB950920.

    The change of cursor type can also mean a change in behaviour. With Dynamic cursors, SQL Server more often optimises for the ORDER BY - part of a SQL query than is the case with Fast Forward cursors. This is because a result set based on a dynamic cursor has to include new rows. IF SQL Server were to choose an index that fits the WHERE clause then it would have to sort all rows according to the ORDER BY before returning the first row to the client and that by definition is a STATIC result-set.

     

    Take this query as an example:

    SELECT * FROM "Demo Database NAV (6-0)"."dbo"."CRONUS International Ltd_$Item Ledger Entry"

    WITH (READUNCOMMITTED)

    undefined (("Document No_"=

    ORDER BY "Item No_","Posting Date","Entry No_"


    With Fast-Forward cursors, in this example SQL Server is likely to try to optimise for the WHERE clause, which is "Document No.". But with the ORDER BY clause specifying a different sorting, SQL Server may then chose a clustered index scan instead.

    With Dynamic cursors, SQL Server is more likely to optimise for the ORDER BY clause, which is a valid and existing index. So in this exampe SQL server would chose an index scan on this index. You can see this by running the query from SQL Server Management Studio like this:

     

    declare @p1 int set @p1=-1

    --declare @p3 int set @p3=16+4096+8192 -- Fast Forward

    declare @p3 int set @p3=2+4096+8192 -- Dynamic

    declare @p4 int set @p4=1

    declare @p5 int set @p5=49

    --declare @p5 int set @p5=15 – FAST 15

    exec sp_cursoropen @p1 output,N'

    SELECT * FROM "Demo Database NAV (6-0)"."dbo"."CRONUS International Ltd_$Item Ledger Entry"

    WITH (READUNCOMMITTED)

    WHERE (("Document No_"=@P1))

    ORDER BY "Item No_","Posting Date","Entry No_"

    '

    ,@p3

    output,@p4 output,@p5 output,N'@P1 varchar(20)',

    'START'

    select @p1, @p3, @p4, @p5

    exec sp_cursorclose @p1

    You can enable / disable the 2nd and 3rd line to switch between Fast-Forward or Dynamic cursor, and see the result in the query plan that gets generated.

     

    How does this affect NAV?
    The change in behaviour can mean that certain queries that ran without problems may be slow, after a customer upgrades the platform to the builds mentioned above. In cases

    that we have seen, the problem has been limited to one or very few specific queries, typically on filtered forms, that were slow after upgrading the platform. Use the query from here:


    Simple query to check the recent performance history II - now including Query Plan information

    to help identifying which queries to trouleshoot. Note that the query shows the Cursor Type in the rightmost column. Then look at whether SQL Server has an index to match the ORDER BY clause.


    Also, be extra careful using the SQLIndex-property on keys. By setting this property, the ORDER BY-clause may not match a SQL index anymore, and a Dynamic cursor will have

    to scan the table.

     

    Why this change?
    Internal performance tests show that overall, Dynamic cursors give better performance and fewer blocks. So while the change may cause unforeseen changes in behaviour when a customer upgrades, overall we have seen better performance with Dynamic cursors.

     

    Lars Lohndorf-Larsen (Lohndorf)
    Escalation Engineer

     

  • Microsoft Dynamics NAV Team Blog

    Customizing style sheets for MS Excel

    • 2 Comments

    As of version 5.0, Dynamics NAV introduced the option to export forms to MS Office (Word or Excel). Data presented on the form are exported in an xml, formatted using style sheets then sent to Word/Excel/Other programs

    A Style Sheet tool for Dynamics NAV has later been released to help partners create custom style sheets for export to Word in an easy and user friendly way. A possibillity for extending functionality to export to Excel might be considered for future versions.

    Meanwhile, customizing style sheets for excel, though requireing basic knowledge in xml and style sheets, can be simplified with some coding handling basic formatting of style sheets.

    The FOB attached contains an example of how to create such a tool, allowing some basic customizations to excel style sheets.

    Style Tool for Excel (xlt)

    The Style Toos for EXceL (xlt) is designed to make it easier to customize style sheets for exporting to Excel. Style sheets have endless possibilities to format your Excel documents. This tool makes some of the most common possibilities simpler, but does not cover all possible changes, so it may not eliminate the need for editing style sheets in external tools, but may help you with some simple customizations.

    Note, this tool was created and tested on  5.01 update 1 client, and assumes using default NavisionFormToExcel style sheet (update 1) as a starting point for customizations.

    To use it with 5.0 client, you might need to modify the tool.


    This is what you can achieve with xlt:
    Define a (font) style to be used on document, for example Bold, color, underline, itallic, etc.
    Define a style for certain condition, for example "Net Change" < 0, "Customer No." = 10000, etc
    Add totals.


    How to use xlt:
    All functionality in the tool can be accessed from form 73000 "XLT Style Card". Run the form and insert a new record to create a new custom style sheet, and specify Code and Description.

    Before you can make changes to a style sheet, you need to import it by clickin on Style -> Import, and choose an existing style sheet for export to Excel (such as NavisionFormToExcel), either from the database or from a file.

    On the Destination tab, specify the table and form IDs that the style sheet will be used for.

    Example:
    Run form 73000 and press F3. Fill out Code:ChartOfAccounts, Description: export Chart of Accounts
    Import the standard NavisionFormToExcel style sheet (by default placed in <client folder>\Stylehseets), by clicking on Style-Import and selecting NavisionFormToExcel style sheet.
    In New XSLT file location field, specify the location of your customized style sheet (example: c:\temp\NewXsltFIleName.xslt).
    On Destination tab, specify TableID=15, select 'Style sheet for this form only' and select form 16, Chart of Accounts.

    Excel Styles:
    You are now ready to customize your style sheet. To create new style, click Design -> Excel Styles. This shows you the styles that were imported with the standard style sheet. From here you can modify existing, or create new ones. To create a new style, press F3, and enter a Style ID.
    Then click on "Edit in Excel (F9)" to define this new style. It will open up Microsoft Excel, and here you can apply any formatting you wish, TO THE TOP LEFT CELL. The style you apply to this cell and it's contents will be imported and applied to all the cells your style applies to. Once you are done applying your style, close and save Excel, and then go back to NAV and confirm to import the style.

    As an example, consider the following scenario: we want to modify the existing label (caption) style and also create a new style (red fonts) that we apply to records in Net Change column with negative value.
    To modify existing label style, click on Design-Excel Styles, press Page Up/Down to browse between records, find Style ID: Label and Press F9 (Edit in excel). In opened excel ark, go to top left cell, in Excel menu select Home-Font and select a different font (for example, Arial Black, size 14). Change also the color to blue. Close the excel and save the file. In NAV client, click on YEs on prompted question (Please apply format in Excel sheet.....). In the Style tab, check that new style is applied  (you should see the record with Option=Font, Property=ss:FontName and Value=Arial Black).

    You can apply same kind of change directly in the Style tab (instead of opening Excel), provided you are familiar with properties and values as defined in Excel. If modifying styles directly in Style tab, remember to click 'Update (F11)' to apply changes to style sheet.

    Note that

    1) moving away from the style by closing the form or moving to the next record will not save any changes you made manually (and not through excel), and

    2) the tool does not validate if changes you do manually are valid.

    Now we want to create a new style and apply it to Net Change column of records with net change < 0.
    Press F3 to create a new style, in Style ID field type RED. Click on F9 (Edit in Excel) and in opened excel sheet click on top left cell. In Excel menu, select Home-Font and select red font color. Close the Style Sheet, answer yes to save changes. In NAV Client answer yes to prompted question (Please apply format in Excel Sheet...). In General tab, You should now see properties defined for StyleID=RED


    Conditional formatting:
    After designing the style(s), then go back to the XLT Style card, and then click Design -> "Conditional Formatting" to apply this style to certain conditions. It is not recommended that you change any of the existing layouts here, but you can create a new one by clicking "Insert (F3)". This opens a mini-wizard where you can specify which columns and values this will apply to.

    To follow our example, we will now specify the condition for using the style created in last step, RED style.
    Close the Excel Styles form and in Xslt style card click on Design-Conditional Formatting. Click on F3 (or click on Insert) to create new condition (it is not recommended to modify any of the existnig, defualt ones). Wizard form opens. We will now create a condition to apply style red to NET Change column with values < 0. Select TableID=15 and Field 32 (Net Change). In Condition field, select'<' anad Value=0. Finally, In Choose style select RED. Click on Finish. You should now see your condition defined in General tab. Condition= (@name='Net Change') and (@value<'0').
    Click on Update to update the style sheet with new condition.


    Totals
    You can specify fields that you want to create totals for, by clicking on Design -> "Total Fields", and select one or more (numerical!) fields. You also need to add one line of C/AL code in codeunit 403 "Application Launch Management". The following line should be added to Codeunit 403, at the top of function LanuchApp:

    XLStyleSheetDataMgt.UpdateDataXML(DataXML,StylesheetID);

    where XLStyleSheetDataMgt is a new local variable, type Codeunit, subtype 73001 ("XLT Style Sheet Data Mgt")

    This will add totals to the data that you export to Excel, and it will add elements to the style sheet to handle these totals. Note: This will not work for RTC because RTC does not make calls to codeunit 403 (see blog here: http://blogs.msdn.com/nav_developer/archive/2008/12/16/dynamics-nav-2009-and-ms-office-integration-send-to-excel-and-word.aspx).


    Export style sheet:
    When you have created one or more style(s) and applied them to certain conditions, then you generate a new style sheet from the "XLT Style Card"  by clicking Style -> Export, and then select to export to file or database. If exporting to database, then a new style sheet will be saved in database, using the Description you have specified in the "XLT Style Card".


    Open form 18 (Chart of Accounts), in toolbar menu, click on send-to button. Select Microsoft Excel and select 'export Chart of Accounts' style sheet., click on OK.
    Chart of Accoutns shoud lbe exported to excelm, with labels in Arial Black font, size 14. Net change column where value < 0 should be marked RED and totals should be present for Net Change column.

    Other functionality:
      - From "XLT Style Card", tab "Standard Styles", specify a style to apply to totals.
      - Click Style -> Reset to re-load the stylesheet, which will erase any changes you have done since you imported it.

     

    These postings are provided "AS IS" with no warranties and confer no rights. You assume all risk for your use.

    All feedback regarding issues or suggestion to this tool are very welcome! 

     

    Jasminka Vukovic, ( jvukovic) and Lars Lohndorf-Larsen (Lohndorf )

    Microsoft Dynamics NO


    Microsoft Customer Service and Support (CSS) EMEA

  • Microsoft Dynamics NAV Team Blog

    Help Toolkit and Help Source Files for Microsoft NAV 2009

    • 1 Comments

    The Microsoft Dynamics NAV 2009 Help Toolkit and the Help Source files are now available for download from PartnerSource.

    We're making the source files for the core Microsoft Dynamics NAV 2009 Help available to Partners so that you can customize the Help to enhance your add-ins or to match the solutions you sell. You can edit the source files and recompile the Help files, or you can copy from the source files into your own Help or other documentation. The source files for the Group 1 countries (Australia, Canada, Denmark, France, Germany, Italy, Mexico, the Netherlands, New Zealand, Spain, the United Kingdom, and the United States) have been released. We will make available the source files for the other countries after NAV 2009 ships for those countries. 

    In a post in September, I mentioned that we were updating the NAV Help Guide and the tools in the Help Toolkit we provide to assist you in creating help. This release of the Microsoft Dynamics NAV 2009 Help Toolkit includes a completely re-written Help Guide, with How To topics, walkthroughs, and guidelines for creating Help and transforming Help for the Classic client into Help for the RoleTailored client. We've also replaced the GATE tool with Help Builder, which is a more robust tool for processing source files and compiling Help files. We've also fixed some bugs in the Generate HTML Help batch job that you can use to generate Help topics for tables, fields, forms, pages, and reports.

    If you have any questions or comments about these two releases, please send an e-mail to navhelp@microsoft.com.

    We continue to be interested in hearing what your needs are, so we can ensure that we are improving the process for customizing and extending Help. You can add your comments below or e-mail us at navhelp@microsoft.com. Here are some questions to get you started:

    • How do you use the content that we provide?
    • What types of Help do you provide to your customers to assist them in using your solution?
    • If you don't provide your customers with customized Help, what are the main reasons for not doing this? How does this impact your support costs?
    • How will you use the source files for all of our Help, in all available languages? Will you customize these CHMs? Repackage Help into another format? Or do something else?
    • Do you extend Help with information about the changes that you have made to Microsoft Dynamics NAV, such as new tables, forms, pages, etc.? How important is it to be able to extend Help? What would make this scenario more efficient for you?
    • Have you used the Help Guide? How well did it help you accomplish Help customization?
    • Do you know that we removed Company Notes in Microsoft Dynamics NAV 5.0 and why? Were you using Company Notes? What worked for you about this solution? What didn't work?
    • If you customize the content that we provide, how do you determine what has changed from version to version?

    It's important for us to ensure that we are providing an efficient way for you to customize the documentation. We're looking for volunteers to test our new Help processes, and provide us with feedback on how well these solutions meet your needs. In return, we'll offer extra assistance in using these processes. If you would like to participate, please e-mail navhelp@microsoft.com.

     - Paul Chapman

  • Microsoft Dynamics NAV Team Blog

    How to enable Document Map in a Report

    • 0 Comments

    Here are the steps to leverage the use of “Document Map” in a Report.

    1. Design Report 113 Customer/Item Sales

    2. Select View / Layout

    3. Right click on Table top left corner

    image

    4. Select Properties

    5. Navigate to “Groups” tab

    image

    6. Select Table1_Group

    7. Select “Edit…”

    8. Select “=Fields!Customer_Name.Value” in “Document map label”

    image

    9. Select “OK”

    10. Navigate to “Navigation” Tab

    11. Enter “Customer” or what you want the title to be in the Document List

    image

    12. Select “OK”

    13. Save and import RDLC changes, and then compile report in Classic client.

    14. Run Report 113, it now looks like this:

    image

    Notice the expand in the top left corner. Unfortunately this does not display anything in NAV 2009 RTM, this will be fixed in SP1.

    clip_image006

    16. Click the expand button to see the Document Map

    image

    17. Now click the customer “Klubben” and notice that the report in to the right navigates to the area where info about the customer “Klubben” is displayed.

    image

    Also check out Waldo's Blog for an example on how to use Document map:
    http://dynamicsuser.net/blogs/waldo/archive/2010/03/04/nav-2009-reporting-document-map.aspx

    Thanks,

    Claus Lundstrøm, Program Manager, Microsoft Dynamics NAV

  • Microsoft Dynamics NAV Team Blog

    Updated April 2nd 2009 - How to add a Company Picture to a Report

    • 7 Comments

    UPDATED April 2nd 2009: Several people have reported to me that the first solution I posted for “How to use the Picture stored in Company Information table:” did not work for them. So I have now updated the section on how to use the picture stored in the Company Information table. The picture is now added in a slightly different way.

    /Claus

    ******

    There are several ways to do this. Either you use the existing Picture which is stored in table 79 Company Information or you can embed the image into the Report itself, or you can link to the picture externally. In this scenario I will be looking at how to use the picture already in the database and and how to embed the picture into the report itself.

    How to embed the Picture:

    1. For us to be able to embed the picture into a report we need to have the Company Picture as a file. I have exported the company picture to c:\temp\CompanyPicture.bmp

    2. Ok, now let us add this to Report 111. Design Report 111

    3. Select "View/Layout" to go into Visual Studio.

    image

    4. Select the Report and choose "Report/Embedded Images"

    image

    5. Select "New Image..." and select your company picture, in my case c:\temp\CompanyPicture.bmp

    image

    6. With that completed open the Toolbox and add a Image control to the Report.

    image

    7. With the Image Control added we need to the set correct properties for this control. Set Source=Embedded, Value=companypicutre and MIMEType=image/bmp

    image

    9. Save and import RDLC changes, and then compile report in Classic client.

    10. Run "dynamicsnav:////runreport?report=111" to open up report 111. And as you can see below company picture is displayed.

    image

    We have no looked at how to embed the Company Picture into the report. Now let us have a look on how to use the Company Picture already in the database.

    How to use the Picture stored in Company Information table:

    1. Deleted the above embedded Company Picture, if you followed the steps above.

    2. Design report 111

    3. Now we need to have a Variable with is references to the Company Information Table. Lets create a new called CompanyInfo

    image

    4. Exit C/AL Globals and ad the following code to the "OnPreReport()" trigger: CompanyInfo.CALCFIELDS(Picture);

    image

    5. Now we should add a Picture Box on the Sections with SourceExpr: CompanyInfo.Picture. We need to do this to have the element available for us in Visual Studio.

    image

    6. It is now time to open Visual Studio. Select "View/Layout"

    7. Notice that we now have an new entry in  the DataSet

    image

    8. Now lets add this to the report. We need to add the Company Picture first as a TextBox to the body of the report. This will enable us to use it in the Page Header. We add this TextBox in top of the Body.

    image

    9. We give the TextBox the following properties:

    Value: “=Convert.ToBase64String(Fields!CompanyInfo_Picture.Value)”
    Name: “CompanyPicture
    Visibility Hidden: “True
    Color: “Red

    10. Now add the following code to the Report properties.

    Shared PictureData as Object

    Public Function GetPicture() as Object
     
    Return PictureData
    End Function

    Public Function SetPicture(NewData as Object)
     
    if NewData>""
       
    PictureData = NewData
    end if
    End Function

    image

    11. Now let us add the Image control just as we did for the embedded scenario. Open the Toolbox and add a Image control to the Report.

    image

    12. With the Image Control added we need to the set correct properties for this control.

    Value: “=Convert.FromBase64String(Code.GetPicture())
    Source: “Database
    MIMEType: “image/bmp

    13. Add textbox to Page Header. Note! This textbox has to be placed above the Picture control just added

    Value: “=Code.SetPicture(ReportItems!CompanyPicture.Value)
    Visibility Hidden: “True
    Color: “Red

    image

    14. Save and import RDLC changes, and then compile report in Classic client.

    15. Run "dynamicsnav:////runreport?report=111" to open up report 111. And as you can see below company picture is displayed.

    image

    Thanks,

    Claus Lundstrøm, Program Manager, Microsoft Dynamics NAV

  • Microsoft Dynamics NAV Team Blog

    How to make Sub Groups in a Page

    • 1 Comments

    In the new RoleTailored client in Microsoft Dynamics NAV 2009 you do not have the possibility to place a field exactly where you want on a page. You can control in which order they should be shown, but where the field will be placed, is up to the RoleTailored client. This is quite different compared to the Classic where we could define Xpos and Ypos for each control.

    Using Sub groups in the Page Designer you can control how fields are grouped. This way you can fix fields to the left side of a FastTab and to the right side of the FastTab. Let see an example of this.

    Here is how the "General" FastTab on the Customer Card looks out of the box with no customizations:

    image

    But adding 2 Sub Groups you can have the General FastTab look this:

    image

    How did I do this? Well let's have look at Page 21 in Page Designer where I have added these 2 groups marked with blue:

    image

    While the "General" and "Group 1" seem very similar in Type and Subtype, the important part to notice here is INDENTATION. My "Group 1" is indented under the "General" FastTab group. And when indented under a FastTab group this will be displayed as group and not as a FastTab.
    Then of course I have indented the fields "No., Name, Address, Address 2, Post Code and City" below "Group 1" to have these fields captured in this group. For "Group 2" I done the same.

    Actually we go one indention level deeper. Try to add a Sub Group in either "Group 1" and "Group 2" and indent some of the fields into to this new sub Group.

    Using Sub Groups gives a bit more control on where fields are placed in the page on the RoleTailored client.

    Thanks,

    Claus Lundstrøm, Program Manager, Microsoft Dynamics NAV

  • Microsoft Dynamics NAV Team Blog

    Platform updates for NAV 5 SP1 Upd1

    • 0 Comments

    This overview of KB-releases and build numbers, is an extension to this one:

    "Servicepacks & Platform Updates for Microsoft Dynamics NAV"

    Links in the table are to the corresponding documentation on PartnerSource (login required), where available.

    DBVersionno for all builds = 95.

    5 Sp1 Build KB Number Released Description
    Update 1

    27191

    956161

    21/08/2008

    Platform Update 1 for NAV 5 SP1.
     

    27199

    957276

    28/08/2008

    In some cases, when filtering, fin.exe and finsql.exe may return different results.
     

    27241

    957267

    27/08/2008

    DBCS character display is inconsistent when entering more characters than are visible in a text box

     

    27253

    954722

    27/08/2008

    NAV may crash when opening and closing many forms that run modally. Often with error 1247 in module 19.
     

    27368

    957219

    12/09/2008

    BizTalk - Sending a document returns error, even if the document was sent OK.

     

    27368

    957471

    16/09/2008

    Backup/Restore of single company can cause - "Company Name <companyname> does not exist" error - Native only

     

    27368

    957733

    23/09/2008

    Indexed views always rebuilt when compiling/modifying/importign table objects in SP1

     

    27398

    957824

    17/09/2008

    Changes in Production Schedule are not saved - Native only
     

    27831

    959911

    13/11/2008

    XMLPort.EXPORT cannot handle DBCS Characters.

     

    27831

    959912

    13/11/2008

    Permissions too restrictive when calculating flowfields with security filters (recordlevel security)
     

    27831

    960141

    17/11/2008

    RunModal error screen when deleting record links in certain cases
     

    28007

    960607

    01/12/2008

    Save report to html can save the wrong space characters.
     

    28028

    960661

    09/12/2008

    Lookup list in report request forms do not open.
     

    28342

    962005

    16/01/2009

    XML Ports do not import data that comes after a white space.

    Lars Lohndorf-Larsen (Lohndorf)

    Microsoft Dynamics UK

    Microsoft Customer Service and Support (CSS) EMEA

  • Microsoft Dynamics NAV Team Blog

    How to get a Dynamics NAV report with a Web Service

    • 8 Comments

    1. Create a new codeunit. In this scenario we will call this codeunit "CUWebReport" with ID 50000

    2. Navigate to "C/AL Globals" and create a function called "GenerateReport"

    image 

    3. Select "Locals"

    4. Select the "Return Value" tab

    5. Set "Return Type"=Text and "Length"=100

    image

    6. With this completed close "C/AL Locals" window.

    7. Now with "C/AL Globals" windows active again. Select "Variables" tab.

    8. Create a variable called "filename" with "Data Type"=Text and "Length"=100

    image

    9. Now let's add the following code to this codeunit:

    filename := 'C:\inetpub\PdfDocuments\';
    filename += FORMAT(CREATEGUID);
    filename := DELCHR(filename, '=', '{-}');
    filename += '.pdf';
    REPORT.SAVEASPDF(111,filename);
    EXIT(filename);

    image

    10. Save and compile the codeunit.

    11. Now it's time to expose this codeunit as Web Service. Navigate to "Administration/IT Administration/General Setup/Web Services"

    12. Select codeunit 50000 and give this a service name, we use "Get_PDF_Report"

    image

    13. Now it is time to verify that we can see this web service. Open this URL  http://localhost:7047/DynamicsNAV/WS/services.

    You should now see this message in your browser, and your Web Service can now be called :

    image

    If you don't see this message, you might want to check that  the service "Microsoft Dynamics NAV Business Web Services" has been started.

    14. Now it is time to call the Web Service, in this example we use Microsoft Visual Web Developer 2005. And we use the following code to call the Web Service:

    Partial Class _Default
        Inherits System.Web.UI.Page

        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim service As localhost.Get_PDF_Report = New localhost.Get_PDF_Report()
            service.UseDefaultCredentials = True
            service.Url = "
    http://localhost:7047/DynamicsNAV/WS/CRONUS_International_Ltd/Codeunit/Get_PDF_Report"
            Response.ContentType = "application/pdf"
            Dim pdfFileName As String = service.GenerateReport()
            Response.TransmitFile(pdfFileName)

        End Sub
    End Class

    But how to consume this Web Service is not in scope for this blog, so we suggest you have look our online help how to consume a Web Service from NAV 2009.

    Online help found here: http://msdn.microsoft.com/en-us/library/dd339004.aspx

    15. Now also remember to impersonate your web servers application to an appropriate Dynamics NAV user.

    16. After compiling a running our project we then get this button in our browser.

    image

    17. When activating this button, we get the report specified in Codeunit 50000 displayed as an PDF file in our browser.

    image

    Conclusion, now you can give this URL to people who don't have access to Dynamics NAV, and they can execute the report when they see a need for this.

    Thanks,

    Torben Meyhoff, SDE & Claus Lundstrøm, Program Manager, Microsoft Dynamics NAV

  • Microsoft Dynamics NAV Team Blog

    Installing the NAV 2009 demo database to a SQL Server named instance

    • 2 Comments

    One of the questions that has been raised frequently is how to install the Dynamics NAV demo database to a named instance of Microsoft SQL Server using the new installation program that was released with Dynamics NAV 2009. The short answer to this question is that this is not supported. However, there is a work around that in fact will allow you to do this.

    Before going into how this can be accomplished there are a few things I need to highlight.

    • You cannot repeat this work around several times on a computer in order to install several demo databases. The work around involves running Windows Installer files (msi) and running such a file a second time will only repair or uninstall the product rather than installing a new instance of the product. You can create a demo database manually using some of the files on the installation media, but this is not within the scope of this blog entry.
    • You must not run the Microsoft Dynamics NAV 2009 installation program (setup.exe) on the computer after you have installed the demo database using this work around since this will uninstalled the demo database. This happens because the Microsoft Dynamics NAV 2009 installation program keeps an inventory of the Dynamics NAV products that have been installed to the computer and will uninstall those which are not in the inventory.

    Now with this in place let's proceed with the work around.

    The task at hand is to install the Dynamics NAV 2009 demo database to a named instance of Microsoft SQL Server 2005. The name of the instance is "CRONUSDEMO" and has already been installed to the computer "CRONUSSERVER" with the service account "NETWORK SERVICE". The Microsoft Dynamics NAV 2009 installation media is located in the DVD drive of your computer (D:\), but it will also work if you install from a local folder or a network drive. You must have administrative privileges on the computer.

    1. Open a Command Prompt on the computer. You must open the command prompt as Administrator if the OS is Vista and you are running with User Account Control (UAC) turned on.
    2. Run the following command:
      msiexec -I "D:\SQLDatabase\Microsoft_Dynamics_NAV_SQL_Database.msi" INSTANCENAME=CRONUSDEMO
    3. Run the following command:
      msiexec -I "D:\SQLDatabase\Microsoft_Dynamics_NAV_SQL_DemoDatabase.msi" INSTANCENAME=CRONUSDEMO

    The demo database is now installed and you should see two entries for this in the control panel.

    To use the newly installed database with the Microsoft Dynamics NAV RoleTailored client you must manually set the Microsoft Dynamics NAV Server to connect to the SQL Server named instance. To do this you must edit the configuration file of the server.

    1. Open the CustomSettings.config file using a text editor. You can find the file in the folder "\Program Files\ Microsoft Dynamics NAV\60\Service".
    2. Locate the DatabaseServer key.
    3. Change the value attribute to CRONUSSERVER\CRONUSDEMO

    You do not have to change any settings on the RoleTailored client in order to connect to the database.

    - Michael Riddersholm Petersen

  • Microsoft Dynamics NAV Team Blog

    GetCompaniesList error configuring Outlook Sync to use Web Services

    • 5 Comments

    In NAV 2009, Outlook Synchronization includes the option to use the new Web Services functionality instead of using C/FRONT and NAS. This is great and demonstrates some of the functionality that Web Services has to offer.

    One issue that can arise when setting this up in a “3 machine” environment is when configuring the Microsoft Office Outlook Add-In. When selecting a company, you could receive an error similar to one of the following.

    The connection to "" Microsoft Dynamics NAV database failed. The program returned the following error: GetCompaniesList error: The login failed when connecting to SQL Server xxx. connection string: NavSynchronizationUrl=http://yyy:7047/DynamicsNAV/WS/Codeunit/DynamicsNAVsynchOutlook;CompanyName=zzz; Please verify your synchronization settings. If the problem persists contact your system administrator.

    The connection to "" Microsoft Dynamics NAV database failed. The program returned the following error:GetCompaniesList error: The request failed with HTTP status 401: Unauthorized. connection string: NavSynchronizationUrl=http://yyy:7047/DynamicsNAV/WS/Codeunit/DynamicsNAVsynchOutlook;CompanyName=zzz; Please verify your synchronization settings. If the problem persists contact your system administrator.

    Note xxx is the server name of the SQL Server (Database Tier), yyy is the server name of the Dynamics NAV Server (Service Tier), and zzz is the company name.

    These errors can occur if NAV Web Services are not setup with the correct SPNs and delegation information. If you haven’t already, make sure your have reviewed the walkthrough on setting up a 3 machine install (found in the nav_install.chm help file, NAV Help can be downloaded here.) and the previous post about setting up NAV 2009 Web Services.

    Scott Wright (scowri )
    Microsoft Dynamics NA

    Microsoft Customer Service and Support (CSS) North America

  • Microsoft Dynamics NAV Team Blog

    NAV 2009 Web Services on a three machine setup

    • 0 Comments

    Much like the setup of the RTC/NAV Server connection in NAV 2009. NAV 2009 Web Services needs to have a SPN added to properly authentic the users accessing it.

    Consider the following scenario in Microsoft Dynamics NAV 2009. You have just completed the “Installing the Three Tiers on Three Computers” walkthrough. The NAV Role Tailored Client (RTC) is working. You have started the Microsoft Dynamics NAV Business Web Services service. When you attempt to view a Web Service URL in a web browser from a client machine you receive a login prompt. If you try to login, you are prompted three times before the process is stopped. An example of possible Web Service URLs is:

    http://xxx:7047/DynamicsNAV/WS//Services
    http://xxx:7047/DynamicsNAV/WS/SystemService

    Note xxx is the server name of the Service Tier. This also assumes that you are using the default port (7047) and default service name (DynamicsNAV).

    This problem occurs because a Service Principal Name (SPN) has not been added to the domain user account running the Microsoft Dynamics NAV Business Web Services service for the HTTP service, which is the normal service name used by web services.

    Resolution

    In order to eliminate the login prompts and allow authorized users to view the Web Services URL, you need to add the following SPNs to the domain user account running the Microsoft Dynamics NAV Business Services service.

    HTTP/FullyQualifiedDomainNameOfNavWebServiceServer
    HTTP/NameOfNavWebServiceServer

    Now, I'm sure you all know if you use the ADSI Edit snap-in, or another utility such as the LDP or LDAP 3 utilities to incorrectly modify attributes to AD objects you could seriously mess up the AD, so be careful. Also, you need to be a domain admin to make the following changes.

    To add the SPNs from a domain server, follow these steps:

    1. Click Start, click Run, type Adsiedit.msc, and then click OK.
      Note The ADSIEdit tool is included in the Windows Server 2003 Support Tools. If you are using Windows Server 2008 the ADSIEdit tool will already be installed. To obtain the Windows Server 2003 Support Tools, visit the following Microsoft Web site: http://www.microsoft.com/downloads/details.aspx?familyid=6EC50B78-8BE1-4E81-B3BE-4E7AC4F0912D&displaylang=en
    2. In the ADSI Edit snap-in, expand Domain [DomainName], expand DC= RootDomainName, expand CN=Users, right-click CN= AccountName , and then click Properties. If you are on a server running Windows Server 2008, you may need to first connect and bind to an instance.
      Notes
      DomainName is a placeholder for the name of the domain.
      RootDomainName is a placeholder for the name of the root domain.
      AccountName is a placeholder for the account that you specify to start the NAV Server service.
      If you specify a domain user account to start the NAV Server service, AccountName is a placeholder for the domain user account.
    3. In the Properties dialog window locate the servicePrincipalName attribute and double click it to open the Editor Dialog window.
    4. Using the following format enter the following two SPNs individually. Click the Add button to add each SPN.

      HTTP/FullyQualifiedDomainNameOfNavWebServiceServer
      HTTP/NameOfNavWebServiceServer
    5. When finished, click OK, and then OK. Finally close the ADSI Edit window.

    Additional Information

    Since Kerberos ticket usually expire after 10 hours, you may need to purge the current Kerberos tickets from client machine before the setup of the Microsoft Dynamics NAV Outlook Add-in can be completed in Microsoft Outlook.

    With Kerbtray.exe, you can easily verify or remove (or both) Kerberos tickets from any of the associated computers that are being used. To download the Kerbtray utility, visit the following Microsoft Web site:

    http://www.microsoft.com/downloads/details.aspx?FamilyID=4e3a58be-29f6-49f6-85be-e866af8e7a88&displaylang=en

    Scott Wright (scowri)
    Microsoft Dynamics NA

    Microsoft Customer Service and Support (CSS) North America

  • Microsoft Dynamics NAV Team Blog

    The COPYSTREAM “problem” for Sockets

    • 0 Comments

    I must say that since I started working in the integration area of NAV (from within NAV), I got very interested in the possibilities that it would bring to NAV developers. Back then, I presented a Web Server for the NAS using the Socket ComCom and since then I have seen how people have used the streams and specifically the MSMQ Bus Adapter for integrating services and data.

    When writing the code for the STREAMS (InStream and OutStream), I thought it would be very useful to write a function that could copy from one to another, reading from the InStream and writing to the OutStream. However, when using Sockets, there is an essential problem to completing this task. Since TCP data can contain anything (literally any data), and since the data size is also unknown and un-limited, how can we know when the copying has been completed?

    Recently I was dealing with a problem that I found within one of the communities forums (yes, we are reading) and it was regarding XMLPorts. You need to stream the data to and from them, so I rapidly wrote a codeunit that would allow me to read the XMLPort to a file; for that, I used the COPYSTREAM function to read from the XMLPort to a FILE. A couple of minutes later, I found out that my file was not filled out correctly as it was truncated, and immediately went into the code to further debug the problem. I quickly found out that the problem was that the COPYSTREAM was not reading till the End of Stream (EOS). I was puzzled to find an error in the COPYSTREAM code after all this years, but of course I thought that the call to the EOS was simply missing. Once I saw that the call was in fact there, it finally hit me…. InStream.EOS is not working, or, it cannot really work.

    The real problem here is, how do we know when a stream will not send us more data? Usually this is done through a protocol (like http, ftp, etc) but without a protocol, it is not possible to have a clear rule when we have the EOS. Is it a NULL termination? Is it 2 x CR+LF? Or what about a dot in an empty line? The truth is that, we could make rules, but we cannot have a generic answer to all possibilities.

    Depending on your specific conditions, and specially the size of the data you are sending, you might not see this problem at all. But maybe, from time to time, you have noticed that data being received gets truncated and you are trying to figure out what went wrong.

    To further illustrate the problem, let’s receive a file using Sockets and Save it on our local file (I’ll skip the sending code unit, but it can very easily be done following the samples provided in the Development Guide for Communication Components):


    COPYSTREAM for Sockets

     

    In the environment where I am writing this, I can send files without any issue up to approximately 25 Kb. After that, everything seems to work fine, except that the file gets truncated, that is, I am trying to send a 48 kb file, but get a truncated one.

    In order to get rid of this problem, I suggest copying the stream one char at a time, so the code could look something like:

    'COPYSTREAM' time based.

    The retry is necessary, because we cannot rely on InS.EOS. InS.EOS also suffers from the fact that we don’t know when the stream will stop sending us data.

    A nicer way to deal with this would be to first send how big the data is. That way, we don’t have to rely on time to assume that the information has indeed completed its transmission. If you are sending XML documents, you could also use the DOMDocument.load(InS) return value, to see if the received data indeed contains a valid XML document. If you have access to codeunit 7700, you can see an example on how this could be achieved (as you need to first copy the stream).

    Of course, as mentioned before… This issue will only happen with the raw SocketBusAdapter.

    Jorge Alberto Torres (jtorres)
    Software Developer Engineer

  • Microsoft Dynamics NAV Team Blog

    What are the Visual Studio options for developing RDLC reports for Dynamics NAV 2009

    • 1 Comments

    Updated 24. September 2009 to include options for Dynamics NAV 2009 SP1. / Claus Lundstrøm

    Today we have the following outlined in our Online Help

    For development of reports for the RoleTailored client, one of the following products is required:

    · Microsoft Visual Web Developer 2005 Express edition SP1 or above

    · Microsoft Visual Studio 2005 Standard or Professional SP1 or above

    · Microsoft Visual Studio 2008 Standard or Professional or above

    Note: If Microsoft Visual Web Developer 2005 edition is used, the Reporting Add-In for Microsoft Visual Web Developer 2005 is also required.

     

    I would like to elaborated on this because other version are also available and we also have a hotfix available for Microsoft Visual Studio 2005 users which need explaining.

    So here it goes. The following editions of Visual Studio are supported:

    Microsoft Visual Studio 2005 Editions:

    · Microsoft Visual Web Developer 2005 Express edition with SP1. With “Reporting Add-In for Microsoft Visual Web Developer 2005

    · Microsoft Visual Studio 2005 Standard or higher editions with SP1

    Tip: If SP1 is not installed for any of the 2005 version you will be asked to convert report when opening Visual Studio from Classic Client. Converting the report will not do any good, so SP1 is required.

    Note: Visual Studio included in SQL Server 2005 is not supported.

    Microsoft Visual Studio 2008 Editions:

      

    Note: ZIndex hotfix is included in SP1 for Visual Studio 2008. ZIndex hotfix issue explained  in the end of this blog post.

    Note about Microsoft Visual Web Developer 2008 Express Edition: NOTE: ONLY IF YOU ARE USING DYNAMICS NAV 2009, SINCE THIS HAS NOW BEEN FIXED IN RELEASED SP1
    Unfortunately this does not work out of the box with NAV 2009 RTM, since “Microsoft Report Viewer Add-on for Visual Web Developer 2008 Express Edition” was released after NAV 2009 RTM.

    When using Visual Web Developer with Report Viewer Add-on, you will be asked to convert report when opening Visual Studio from Classic Client. Converting the report will not do any good.

    There is a workaround for this:

    1. Navigate to “C:\Program Files\Microsoft Dynamics NAV\60\Classic”

    2.  In this folder there is 2 folders called “ReportLayout2005” and “ReportLayout2008”

    3. Copy all files from “ReportLayout2008” to “ReportLayout2005”

    Doing this will of course kill support for “Microsoft Visual Studio 2005” and “Microsoft Visual Web Developer 2005 Express” on this specific client, but now Visual Web Developer 2008 works, and you no longer get the convert report message. We plan to have this issue resolved in SP1 for Microsoft Dynamics NAV 2009, so there is no need for this manual workaround.

    ZIndex issue:

    • Without ZIndex hotfix:

    When making any change to a report in Report Designer(Visual Studio) all ZIndexes will be updated in the RDLC.

    • With ZIndex hotfix:

    When making any change to a report in Report Designer(Visual Studio) only ZIndexes for the specific change will been updated.

    Having the ZIndex hotfix installed will make comparing of changes in between version of a report easier.

    Hotfix works for all Visual Studio 2005 versions. ZIndex hotfix is included in SP1 for Visual Studio 2008, but please notice that hotfix is not available in Visual Studio 2008 without SP1.

    Read more about the ZIndex hotfix for Visual Studio 2005, and how to obtain here.

    Thanks,

    Claus Lundstrøm, Program Manager, Microsoft Dynamics NAV

Page 34 of 43 (638 items) «3233343536»