cancel
Showing results for 
Search instead for 
Did you mean: 

Possible solution: Open Crystal Reports Print Layout from UDO form

Former Member

Hi all,

I recently had to print information of a UDO which I have on a new form. I searched through the forum and found different solutions, but none that used the new "integrated" crystal reports viewer. So I came up with this workaround, which so far works great. I post it here for anybody else needing this kind of workaround, or in case somebody has a better solution, pick that up.

Here it is:

1) Create your Crystal Report file and import using the Reports and Layouts screen in SAP Business One. Give it a meaningful name and location in the menu. Have at least one parameter to take the DocNum or DocEntry, or whatever your primary key is. (Note: I know the import can be done by SDK, but as far as I can see there's no way to place it in the menu structure just yet.)

2) In your Add-On in the event ID 520 (print), call the following function with the Document Number grabbed from the open form:


public static bool printUDO(string strDocNum)
        {
            // get menu UID of report
            Recordset oRS = (Recordset)B1Connections.diCompany.GetBusinessObject(BoObjectTypes.BoRecordset);
            oRS.DoQuery("SELECT MenuUID FROM OCMN WHERE Name = 'ReportName' AND Type = 'C'");
            if (oRS.RecordCount == 0)
            {
                B1Connections.theAppl.MessageBox("Report layout 'ReportName' not found.", 0, "OK", null, null);
                return false;
            }

            // execute menu and enter document number
            B1Connections.theAppl.ActivateMenuItem(oRS.Fields.Item(0).Value.ToString());
            Form form = B1Connections.theAppl.Forms.ActiveForm;
            ((EditText)form.Items.Item("1000003").Specific).String = strDocNum; 
            form.Items.Item("1").Click(BoCellClickType.ct_Regular); // abrir reporte
            return true;
        }

I know it's kind of a dirty solution, but it works, and if you have any suggestions, I'd be happy to hear them.

Thanks!

Joerg.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Joerg Aldinger ,

thanks good solution dear for udo

Thanks

Rajkumar Gupta

Former Member
0 Kudos

Hi Joerg,

It's not a dirty solution... I like it and i'm using it

Thanks!

Best regards,

Ana Silva

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Sorry, I edited this message by mistake...