Printing Dynamics SL report from button on screen

May 23, 2011 4 comments

The typical way to add a custom report to a Dynamics SL installation is to add it to a menu so that when a user clicks the report link, the ROI screen is displayed to let the user select additional options.

ROI

Sometimes it makes sense to bypass this and just have a user click a button on a screen and the report prints immediately (sometimes called “Quick Print” mode).

To do Quick Print, you still call ROI, but pass some parameters to it to tell it to go ahead and print (or print preview) the report without appearing to prompt the user for more input.

The basic syntax is:

ROI.exe 12345/RUN Fmt/FORMAT /PSCRN

where 12345 is the 5 digit report number that you want to run and Fmt is the format

In the Report Control Maintenance screen above, the Trial Balance report is pulled up (Report Nbr 01610).  The Combined Totals format uses 01610a.rpt and the Debit and Credit Totals uses 01610b.rpt.

If you wanted to print the Debit and Credit Totals format of the Trial Balance report, you would call:

ROI.exe 01610/RUN 01610B/FORMAT

This would print it directly to the default printer.  If you wanted to do a Print Preview instead, you would call:

ROI.exe 01610/RUN 01610B/FORMAT /PSCRN

If you wanted to add a WHERE clause filter (similar to adding lines to the SELECT tab of the ROI screen), you would use the /WHERE parameter. (Use the SELECT tab to see the exact field names.)

ROI.exe 01610/RUN 01610B/FORMAT vr_01610b.accthist_acct=’1010’/WHERE

would filter the report to show only Account ‘1010’ values.

There are more ROI parameters available, but this is a good start. For more details, consult the ROI user guide (sl_roi.pdf in the User Guides folder).

To call from the SL SDK (formerly VB Tools), use this syntax:

Call CallApplicWait(“ROI”, “01610/RUN” + PRMSEP + “01610B/FORMAT”  + PRMSEP + “vr_01610b.accthist_acct=’1010’/WHERE” + PRMSEP + “/PSCRN”)

To call from a customization, use this syntax:

serr1 = Launch(“ROI.EXE” + PRMSEP + “01610/RUN” + PRMSEP + “01610B/FORMAT” + PRMSEP + “vr_01610b.accthist_acct=’1010’/WHERE” + PRMSEP + “/PSCRN”, True, True, 0)

Advertisements

Video overview of Dynamics SL customization levels

I posted a short video on YouTube that explains how customization levels work in Dynamics SL.

Problems with SL SDK (VB Tools) programs running on 64 bit systems

If you create a new program for SL 7 using the SDK (formerly VB Tools) and it runs fine on a 32 bit system but crashes at startup on a 64-bit system (I was getting a Bad Image error), you need to change a compile setting in VB.Net.

The SL SDK project template sets the TargetCPU to “AnyCPU” by default, which means it will run as 64-bit on a 64-bit system.  SL programs have to run in the WOW64 subsystem on 64-bit systems so you need to change this setting to x86.  You can find it on the Compile tab of the Project Settings page (click the Advanced Compile Options button).

Dynamics SL VBTools Application Upgrade Utility only works with Visual Studio 2005

April 20, 2011 2 comments

Even though the Dynamics SL SDK officially supports using Visual Studio 2008, I found out the other day that I had uninstalled VS2005 too quickly.  The Application Upgrade Utility that came with the 7.0 SDK to help you convert your SL 6.5 VBTools programs is apparently hard-coded to use the VB 2005 conversion utility (the Artinsoft utility – VBUpgrade.exe).

If you haven’t converted all of your (or your clients’) old VB Tools applications – you need to keep VS 2005 around.

Overriding Dynamics SL’s built-in SQL error handling

April 14, 2011 Leave a comment

From the Dynamics SL SDK User Guide – “By default, all error codes except 0 and NOTFOUND are trapped within SWIM and are not returned to the application.” In practice, this means that SWIM pops up an error message and aborts the current transaction.

If you need more control over the error handling, you can use a little-used part of the SDK.  The SqlErrException function lets you tell SWIM to pass SQL errors back to your program so you can handle them.

An example will help. I wrote a program that lets an SL user override the default printer in cases where the report is not printed from the ROI screen (for example, the Print button on the Purchase Order screen).  It is called by replacing the pre-process defined for reports in the RPTControl table, but my program needs to call the original pre-process if there is one.  Since the value in the RunBeforeApplic field can be a stored procedure or an executable file name, the program needed to be able to call either one.

The program first assumes that the value is a stored procedure and tries to execute it via the SQL function.  If that value isn’t actually a stored procedure, an error will be generated (Error #102 in this case). Normally, this would result in an error message being popped up, but I needed to handle it more gracefully. That’s where the SqlErrException function comes in.  Here’s the code:

                ‘The first call with the EXCEPTION_ON parameter tells SWIM to not handle error 102
                Call SqlErrException(EXCEPTION_ON, 102)
                ‘Try to call the stored procedure
                Call sql(c5, sSolPreProc + IParm(iRIID))
                ‘The SqlErr function returns any unhandled error
                strErr = SqlErr()
                ‘Set the error handling back to the default
                Call SqlErrException(EXCEPTION_OFF, 102)
                ‘If an error 102 was encountered, we know the RunBeforeApplic value wasn’t
                ‘a stored procedure, so we need to execute it

                If strErr = 102 Then
                    Call CallApplicWait(sSolPreProc, CStr(iRIID) & PRMSEP & “PRINT” & PRMSEP & “Y”)
                End If

Temporarily turn off customizations

March 30, 2011 Leave a comment

If something strange is happening and you need to see if a customization is causing a problem, you can temporarily turn off all customizations by going to Administration and run Select Customization Level from the Utilities section.  Select the Standard radio button and click OK.

This only affects your session and the next time you start SL, it will default back to Self which loads all customizations. (Of course, you can come back here and manually choose Self to turn the customizations on again as well.)

More info on SL7, FRx, Windows Authentication, and FRx32.OFSIMain.CheckOFSIConnection error

November 16, 2010 2 comments

If you get an error like the one below, keep reading.

 “The login failed for the ______ company. Make sure the login ID and password are correct and verify the settings on the System Specific Information page in Company Information” with additional details of r”FRx32.OFSIMain.CheckOFSIConnection – 5: Unable to create RDO Environment. Please verify DSN information”

Basically this means that FRx isn’t able to connect to the SQL database as it expects to.

After my initial post about Windows Authentication, I’ve gotten several comments/questions specific to FRx.  Here’s what I’ve figured out since then. Read more…