Showing results for 
Search instead for 
Did you mean: 

How does the SetDefaultReport Method really work?

Former Member
0 Kudos

I've looked in the forum and can't find the answer in enough detail for me to understand it.

I need to create a new print button on a system form (delivery notes) and when the user presses it, I need to change the default report for the user/bp combination on the screen, invoke the print button, then return the user's records in the RDFL table back to what they were before I made a change.

I have it working so that everything up to the changing things back is fine. (Although if the user doesn't have any defaults already, then I have to set the same default twice, because the first set assigns the system values, even though I assign a reportcode, layout code, card code and user id).

But the main problem is if the user/bp combination did not have a default specified in RTYP before I made my change, then I can't get rid of my default record in that table, so the next time the user goes to print via the system print button, hoping to get the system default, my default report is going to print instead and that's not what they want. Whew!

Is there some place on the website that might explain this process in some detail? For instance, why are their records in this table with a negative userid number & what does that mean? Why does the user need to be a super user for me to do this via the DI but they can do it through the application without being a SU?

I'd really appreciate any insights, and thank you.

View Entire Topic
Active Contributor
0 Kudos

Hi John..

Strange, but it is incredible how your story look like mine... I've did exactly the same as you, but came to the same end/conclusion

SetDefaultReport seem to work, but I cant get GetDefaultReport to work (so I can reset the layout after the specific print) when user/bp settings is in effect.

It also seem that there are left some data in the RDFL table that should not be there, but i guess that the negative usercodes and bp indicates that they are not in use...

My test of all this is a while back and it was only a proof of concept so sorry that i've forgot some of the details... My plan was to check back at this when SBO2006 was out (To see if anything was changed)...

Former Member
0 Kudos

Hi Rasmus,

In regards to your trouble getting the default report so that you can set it back when your done, I think I've gotten that figured out. It appears to me that GetDefaultReport always returns the original default for a document that is used (from the RTYP table). This is regardless of user/customer. What I'm doing is looking in RDFL by user & customer for any specific default and use it if found.

If not found, then I use the getreportdefault & assign it to that user/customer. This puts a record in RDFL which is not the way the system would do it (It would delete the record, I believe), but it seems to have the same effect.

            'get current default report for this user for delivery docs
            ReportCode = "DLN2"
            rs.DoQuery("Select dfltreport from rdfl where userid = " & USERID & _
                    " and doumntdode = '" & ReportCode & "' and cardcode = '" & cardcode & "'")
            If Not rs.EoF Then
                HoldLayout = rs.Fields.Item(0).Value

                'otherwise use the system default
                'get report layout service
                oReportLayoutService = oCmpSrv.GetBusinessService(ServiceTypes.ReportLayoutsService)

                'get report params
                oReportParams = oReportLayoutService.GetDataInterface(ReportLayoutsServiceDataInterfaces.rlsdiReportParams)

                'Load the key for the default report
                oReportParams.ReportCode = ReportCode
                oReportParams.UserID = USERID 'This doesn''t seem to work. Changing user doesn''t change results
                'get the default layout of the specific document (delivery note)
                oReportParaDefault = oReportLayoutService.GetDefaultReport(oReportParams)
                HoldLayout = oReportParaDefault.LayoutCode
            End If