Shutting down a report

afarrafarr Member Posts: 287
One of our clients has a US branch, so they want to have both US and standard (W1) functionality.
There are a few hundred objects in the 10,000 range that exist only in the US version, so of course we imported those into the database. However, some of the reports replace standard reports, e.g. the W1 database has Report 8 called Budget, and the US database has report 10001 called Budget. We changed the name of Report 10001 to “Budget – US”, since in Navision all reports must have distinct names.

Now, if anyone in the US branch runs report 8, we want report 10001 to run instead, and close down report 8.
CurrReport.QUIT doesn’t seem to have any effect *by itself* if placed in OnInitReport. In fact the request form still runs, and RequestOptionsForm.CLOSE in the form also seems to be ignored.
I finally found something that does work – this is the code that I put in OnInitReport, and it does exactly what I want. Note that the second report is run using RUNMODAL, because if I use RUN then when Report 8 shuts down, Report 10001 also shuts down.
CompanyInformation.GET;
IF CompanyInformation.Country = CompanyInformation.Country::USA THEN BEGIN
  REPORT.RUNMODAL(10001);
  CurrReport.USEREQUESTFORM := FALSE;
  CurrReport.QUIT;
END;

(There are also many standard objects which are different in the US version, so we have to merge that functionality into the curent database, but that’s a separate issue.)
Alastair Farrugia

Comments

  • David_SingletonDavid_Singleton Member Posts: 5,479
    I can just hope that you don't go this path. I know there are a lot of people in the community that think that helping you solve this issue is to help you, but its not.

    This really is a bad solution.

    You need to start from the business process, an work out how you train people to do their jobs. work with the client and help them to do this in a business way. Don't try to replace process design with C/SIDE.
    David Singleton
  • kapamaroukapamarou Member Posts: 1,152
    If the report is executed from a Menu then just train the users to run the report that they need. For example ReportA - US, ReportA - W1.

    Probably if they run the wrong report they will get something different that doesn't cause any problems with the Database.

    If it is possible I would set up permissions to allow people to execute the report, or assign different Menus to users...
  • afarrafarr Member Posts: 287
    edited 2008-10-17
    Hi David,

    I'm not sure I understand your point (I'm also happy to have figured out the technical problem, so that might colour my judgment – we think our own babies are beautiful no matter how other people may see them :-) ).

    Of course there are different procedures to follow in the US (because of different laws and regulations), but the choice of one report instead of another is something that can be automated, because people in the US company should always run "Budget US", while those in the other company should always run the Budget report.

    If there is a menu item for running the Budget report (no. 8 ), we could add another item for “Budget – US” report (no. 10001) and tell US employees to make sure to always choose the “Budget – US” link, but I don’t see how that is better than having one link which automatically runs the appropriate report. I suppose that this is not what your post was about – maybe I’m missing the point completely.

    If you were going about this, how would you have provided the US functionality (in a database that also has W1 or GB functionality)?

    Alastair
    Alastair Farrugia
  • DenSterDenSter Member Posts: 8,305
    The reason that this is not a good solution is that you hard code running a different report (modally at that) inside another report, which is just not a good idea. You solved a technical problem, and I'm glad you did, but it does not solve the business requirement.

    If I were you I would to expand the standard NAV report selections functionality to include a country parameter. That way you can set report number x for country 1, and report y for country 2, and none of the actual reports will need to have any code to run any other report. You could then add the value of the country parameter in a number of different ways. Maybe adding the country as an attribute to User Setup and retrieve it there per user, or maybe adding it to a location or responsibility center, or something like that.

    Don't think along lines of hard coding anything, that is never a good solution. Always try to come up with a solution that allows users to set up their system themselves.
  • kinekine Member Posts: 12,562
    And what about using permissions to limit which report can the user run? I thing it will be much cheaper and quicker to do than making it through the code. The menusuite will show only allowed report...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • krikikriki Member, Moderator Posts: 9,110
    [Topic moved from 'NAV Tips & Tricks' forum to 'NAV/Navision' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.