Page 1 of 1

Bug in Logical Printer Search Code

PostPosted: Wed Sep 23, 2026 6:14 pm
by SBarnes
I think there is a possible bug in the search mode for logical printers as the following code produces an error about invalid object name SY_LogicalPrinters which is not a table in the database.



Code: Select all
public void ButtonClicked(JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic BusinessLogicHost, JiwaFinancials.Jiwa.JiwaApplication.Controls.JiwaGrid GridObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm FormObject, int Col, int Row, JiwaFinancials.Jiwa.JiwaApplication.IJiwaCustomFieldValues HostObject, JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomField CustomField, JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomFieldValue CustomFieldValue)
    {
      if(CustomField.PluginCustomField.Name == "SalesOrderPrinter" || CustomField.PluginCustomField.Name == "DeliveryDocketPrinter")
      {
         System.Diagnostics.Debugger.Launch();
         System.Diagnostics.Debugger.Break();
         var search = BusinessLogicHost.Manager.Search;

         //JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.clsSearch.SearchModes searchMode = JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.clsSearch.SearchModes.jswArchivingJobs;

         search.Clear();
         JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.clsSearch.SearchModes searchMode = JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.clsSearch.SearchModes.jswLogicalPrinters;
         search.SetDefaultSearch(ref searchMode);
         search.UsePinBoard = false;


         if (search.Show((System.Windows.Forms.Form)BusinessLogicHost.Client) == DialogResult.OK)
         {
            //System.Diagnostics.Debugger.Launch();
            if (search.Results.Count > 0)
            {
               var idField = (JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.Field)search.get_Fields(1);

               CustomFieldValue.Contents =  idField.FieldValue.ToString();
               JiwaFinancials.Jiwa.JiwaApplication.PrintGroup.Maintenance.LogicalPrinterCollection logicalPrinters = BusinessLogicHost.Manager.CollectionFactory.CreateCollection<JiwaFinancials.Jiwa.JiwaApplication.PrintGroup.Maintenance.LogicalPrinterCollection, JiwaFinancials.Jiwa.JiwaApplication.PrintGroup.Maintenance.LogicalPrinter>();
                   logicalPrinters.Read();
               CustomFieldValue.DisplayContents = logicalPrinters[CustomFieldValue.Contents].Name;
            }
         }         
      }
      
    }


The sql produced is

Code: Select all
SELECT SY_LogicalPrinters.RecID, SY_LogicalPrinters.Name, SY_LogicalPrinters.PhysicalPrinterName FROM SY_LogicalPrinters
ORDER BY SY_LogicalPrinters.Name


Re: Bug in Logical Printer Search Code

PostPosted: Wed Sep 23, 2026 6:24 pm
by Mike.Sheen
Thanks - logged as DEV-13085.

We never have a need to search for a logical printer, so we've not bumped into this. We'll be nice and make it work, rather than remove it.

Re: Bug in Logical Printer Search Code

PostPosted: Wed Sep 23, 2026 6:30 pm
by SBarnes
:lol: I'll be nice and post the code for doing the search as a raw SQL to make it work in case anyone needs it in the meantime but that's a job for the morning