Page 1 of 1

Process sales order. Stop the Print Type dialog appearing

PostPosted: Tue Oct 04, 2022 1:31 pm
by DannyC
Hi,

When I process a sales order via the sales order screen I want to stop the print selection from appearing & just process the sales order.
Process print.png
Process print.png (5.99 KiB) Viewed 2060 times


In my scenario based on a debtor custom checkbox, if the debtor is ticked then when a sales order is processed just print and email without displaying the dialog above.
What's the trick to stopping it displaying?

Re: Process sales order. Stop the Print Type dialog appeari  Topic is solved

PostPosted: Tue Oct 04, 2022 2:25 pm
by Scott.Pearce
Handle the SalesOrderForm.UltraToolbarsManager1.ToolClick event (Add your handler in SetupBeforeHandlers so your handler is executed first).

In *your* SalesOrderForm.UltraToolbarsManager1.ToolClick handler, create a reports collection and add to it the reports you want to print, i.e.:

Code: Select all
'if this is a special debtor as per your debtor custom field

    Dim candidateReportsToPrint As JiwaApplication.JiwaCollection(Of JiwaApplication.PrintGroup.SalesOrderReports.SalesOrderReport) = salesOrderForm.SalesOrder.GetCandidateReportsToPrint()

    Dim reportsToPrint As JiwaApplication.JiwaCollection(Of JiwaApplication.PrintGroup.SalesOrderReports.SalesOrderReport) = Manager.CollectionFactory.CreateCollection(Of JiwaApplication.JiwaCollection(Of JiwaApplication.PrintGroup.SalesOrderReports.SalesOrderReport), JiwaApplication.PrintGroup.SalesOrderReports.SalesOrderReport)

    For Each salesOrderReport As JiwaApplication.PrintGroup.SalesOrderReports.SalesOrderReport In candidateReportsToPrint
        'Put an if statement here to determine if it's a report you want to print
        reportsToPrint.Add(salesOrderReport)
    Next

    salesOrderForm.SalesOrder.Process(reportsToPrint)

    'Re-read after processing
    salesOrderForm.ProposedDrillDownID = salesOrderForm.SalesOrder.InvoiceID
    salesOrderFormReadRecord(ProposedDrillDownID)   

    'This stops the Jiwa handler from executing (you have already done the work).
    Throw New JiwaApplication.Exceptions.ClientCancelledException
'Else
    'Don't do anything and the dialog will display as per normal
'End If


Re: Process sales order. Stop the Print Type dialog appeari

PostPosted: Tue Oct 04, 2022 3:11 pm
by DannyC
Thanks Scott.

That did the trick! Muchos gracias

Re: Process sales order. Stop the Print Type dialog appeari

PostPosted: Tue Oct 04, 2022 3:12 pm
by Scott.Pearce
No problem.

Re: Process sales order. Stop the Print Type dialog appeari

PostPosted: Thu May 04, 2023 5:26 pm
by DannyC
Client has come back to me with a little issue.

When the period is locked, they get the dialog that the period is locked. All good there.
But the sales order sits there with the save & cancel active & it would seem the user defaults to saving the order.
This sets the sales order as processed, but really it hasn't.

When the user clicks OK on the Period Lock dialog, I want to automatically cancel.

I've tried just doing a read but that doesn't work.
Code: Select all
salesOrder.Read(salesOrder.InvoiceID);


Tried doing this also but that didn't help either.
Code: Select all
throw new JiwaFinancials.Jiwa.JiwaApplication.Exceptions.ClientCancelledException();


How can I get the sales order to automatically cancel when the period lock dialog is displayed?

Re: Process sales order. Stop the Print Type dialog appeari

PostPosted: Thu May 04, 2023 5:39 pm
by SBarnes
I would suspect that the sales order is throwing an exception and has bailed out leaving the order in the state it is then the user interface has shown the exception in a message box, the easiest way I can think of getting around the problem is attaching to one of the processing events like when processing starts and check the period yourself if its locked then show the user a message box and then simply reread the order and finally throw a client cancel exception to stop any further events.