Page 1 of 1

salesOrderForm.SalesOrder.CreateEnd not firing for credits

PostPosted: Thu Jan 25, 2018 12:48 pm
by DannyC
Hi,
Just writing a fairly simple plugin on salesOrderForm.SalesOrder.CreateEnd.

It needs to run for both sales orders and credit notes but I've just proven that it doesn't run the Sub if it's a credit note. Version 7.1
Is this normal?

Cheers

Re: salesOrderForm.SalesOrder.CreateEnd not firing for credi

PostPosted: Thu Jan 25, 2018 10:36 pm
by SBarnes
Hi Danny,

You may find that the behaviour doesn't run if you create the credit note from an existing order but will run if you create the credit note and don't relate it to an existing order at least that's my experience.

Why this is the case though I don't know.

Re: salesOrderForm.SalesOrder.CreateEnd not firing for credi

PostPosted: Mon Jan 29, 2018 9:14 am
by Mike.Sheen
Hi Danny,

I believe the Created event is fired for all types of sales order (from quote, credit note from existing so, et cetera) - the CreatEnd isn't fired in all circumstances because of difficulty with the UI handling all scenarios correctly.

Mike

Re: salesOrderForm.SalesOrder.CreateEnd not firing for credi

PostPosted: Wed Jan 31, 2018 8:45 am
by DannyC
This doesn't work. Error on compile...
Code: Select all
    Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
       Dim salesOrderForm As JiwaSalesUI.SalesOrder.SalesOrderEntryForm = DirectCast(JiwaForm, JiwaApplication.IJiwaForm)
      'AddHandler salesOrderForm.SalesOrder.CreateEnd, AddressOf GetUSDFX
      AddHandler salesOrderForm.SalesOrder.Created, AddressOf GetUSDFX
    End Sub
   
   Private Sub GetUSDFX(sender As Object, e As System.eventargs, NewSalesOrderType As JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder.NewSalesOrderTypes, SourceQuoteObject As JiwaFinancials.Jiwa.JiwaSales.SalesQuote.SalesQuote)
.
.
.

Method GetUSDFX does not have a signature compatible with delegate....
I'm pretty sure I have all the passed in objects which the Created event needs, so not sure on fixing up this error.

Re: salesOrderForm.SalesOrder.CreateEnd not firing for credi  Topic is solved

PostPosted: Wed Jan 31, 2018 8:51 am
by Scott.Pearce
The event CreateEnd expects a signature like:

Code: Select all
GetUSDFX(sender As Object, e As System.EventArgs)


(and "sender" will be a sales order object).

Whereas Created expects a signature of:
Code: Select all
GetUSDFX(sender As Object, e As System.EventArgs, ByVal NewSalesOrderType As NewSalesOrderTypes, ByRef SourceQuoteObject As JiwaSales.SalesQuote.SalesQuote)

(and "sender" will be a sales order object).

Note that the Created signature expects ByRef SourceQuoteObject As JiwaSales.SalesQuote.SalesQuote - I suspect this is your problem. Insert the ByRef keyword into your declaration.

Re: salesOrderForm.SalesOrder.CreateEnd not firing for credi

PostPosted: Wed Jan 31, 2018 8:56 am
by DannyC
yay - and so fast too. I needed ByRef.

cheers

Re: salesOrderForm.SalesOrder.CreateEnd not firing for credi

PostPosted: Wed Jan 31, 2018 9:09 am
by Scott.Pearce
8-)