InitializeTransaction Hook Firing Twice

Hi,

The InitializeTransaction Hook fires twice after a transaction is posted.

Is this normal? Is there any transaction or session property I can check to see which of the two events I should react to?

Is there any way of displaying the Customer Selection dialog from within a hook event?

Reply to
Mick Hardy
Loading thread data ...

It's normal in that it happens every time, although I don't think it is an intended behavior. There are some other hooks that will fire more often that you would expect as well - RefreshDisplay seems almost random.

You could use one of the custom variables on the session object to set a flag that you could check. You're going to have to test behavior there as well - I *think* that the session variables get cleared when a new transaction starts (before Initialize Transaction), but I may be wrong - you may have to reset them yourself late in the transaction workflow - maybe PrintReceipt...

Glenn Adams Tiber Creek C> Hi,

Reply to
Glenn Adams [MVP - Retail Mgmt]

Glen is right that you should set a flag of some sort. Since the session variables are not reset through transactions you can do something like: set a flag in a session variable with the current transaction number. Then check if the flag is the same as the current transaction number, this would be the second call to Init Transaction.

- Evan Culver New West Technologies

"Glenn Adams [MVP - Retail Mgmt]" wrote in message news:%23$nU% snipped-for-privacy@TK2MSFTNGP06.phx.gbl...

Reply to
Evan Culver

Hi Glenn,

Thanks heaps for your help and all your previous posts that got me started with hooks in the first place.

I didn't know about Session variables. They don't get reset between Transactions, which will be great for flags. Incidentally Session.Variables(0) simply doesn't work but doesn't error. Session.Variables(1) or greater works as expected.

Unfortunately they won't help here as I have nothing to store or test against. TransactionNumber and OrderID are always zero in the InitializeTransaction event. I've tested just about every property I could find.

If the event always fired twice, I could set the flag so I only run my code once but in some circumstances, such as the very first transaction, the event only fires once as expected.

Reply to
Mick Hardy

Just reset the flag in a later firing hook - PrintReceipt maybe. I think you might be able to use refreshScreen, but like I said before, it gets called at some odd times. if the flag isn't set, like on the first transaction, go ahead and run...

Glenn Adams Tiber Creek C> Hi Glenn,

Reply to
Glenn Adams [MVP - Retail Mgmt]

Hi Evan,

Thanks for the suggestions. Session Variables work great but the transaction number and OrderID are always zero in this event so I have nothing to test against. Even if you set something in the Transaction itself such as the Reference Number or type of transaction, this is cleared on the second fire. It appears as if the first Transaction is simply thrown away. It must be a bug.

I've split my code across two hooks now. I set the default transaction type to Work Order if it hasn't been set already in the InitalizeTransaction event. It doesn't really matter that this happens twice.

My custom form for entering the Customer Order Number, which I store in the ReferenceNumber field is only displayed if it hasn't been set when the Begin Tender hook fires. The original problem was this custom form would be displayed twice.

I realise you can display the Details form automatically but it wasn't quite what I wanted as I specifically wanted the field to be labelled Customer Order Number.

Thanks again for your help. This workaround will be OK. I guess I just wanted to make sure the double firing wasn't something messed up with my installation or the Retail Realm addins.

Reply to
Mick Hardy

Thanks Glenn. Sometimes I miss the simple solutions. I've got so many workarounds under test, I lost track. If I assume the event always fires twice after a transaction is posted and it appears to be consistent, the flag suggestion works fine.

I'm still trying to work around the event firing when the application is closing.

Reply to
Mick Hardy

BeanSmart website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.