NetTalk Central

Author Topic: Browse not saving data back to database?  (Read 4832 times)

Devan

  • Full Member
  • ***
  • Posts: 230
    • View Profile
    • Email
Browse not saving data back to database?
« on: February 10, 2014, 06:09:01 PM »
Just got a very concerning heads up from one of my clients that they are experiencing an issue with a NetTalk app I wrote for them.  They have shown me instances where a Browse screen (order form) does not appear to be saving SOME information back to the back end SQL database.

There is no real extra coding etc. on the browse that I think could be doing it - pretty standard NetWebBrowse embedded in a form.

As you can see on the attached screenshots - ALL the lines have quantity, price and line total, yet when we print the order report, two of the lines STILL have the quantity, but no price and line total?!?  Checking the database shows that the price and line total of those order lines are zero!

Seems to be intermittent.  This particular site has been up for over a year, but the problem seems to have raised it's head in the past few months, around the time I did an upgrade for them using 7.31 (or thereabouts) of NetTalk.

Anyone else seen this, or can shed some light on why this may be happening?

Cheers,
Devan



[attachment deleted by admin]

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Browse not saving data back to database?
« Reply #1 on: February 10, 2014, 10:14:04 PM »
as you can see in the browse screen-shot though, the data did exist in the table. Does it still exist in the browse now, or has it zero'd there as well?

that browse is not using EIP as far as I can see, so it's not responsible for "saving anything to the backend". Browses display data which is already there, they don't write data (unless you have EIP active) so if the data changes to 0 at some point, it's because you have code to write a change somewhere.

I'm guessing they didn't take a random screen-shot of the browse - they either expected the fields to go to zero (in which case they're duplicating this problem on demand?) or they edited the records _after_ they noticed the report?

If the problem is easy to duplicate then it should be easy to debug, and find out where the records are being cleared. I'm thinking you should start by asking the client exactly what they are doing, and for that matter why they took those 2 specific screen-shots.

cheers
Bruce

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Browse not saving data back to database?
« Reply #2 on: February 10, 2014, 11:01:24 PM »
I'd be looking at what is in the DB and working forward from that.

I've also started logging everything users do so I can track what really happened.

Devan

  • Full Member
  • ***
  • Posts: 230
    • View Profile
    • Email
Re: Browse not saving data back to database?
« Reply #3 on: February 11, 2014, 10:42:38 PM »
Thanks for the replies Kevin & Bruce.

Bruce - good call about the timing of the screenshots.  It turns out that the web screenshot was AFTER they found the missing data in the report.  I was amazed that the pricing appeared again AFTER it was zero in the database.

I checked the code again, and there IS a routine being called when the browse fields are being built.  Upon the Value::Routine embed for the LIN:Price field, a procedure gets called to calculate the default item price (It is a stupidly LONG and complicated pricing calculation).

I am thinking that this price is getting kludged at some other point when saving?

In the Value::Routine for the LIN:LineTotal field, I have a simple formula which is just LIN:LineTotal = LIN:Price * LIN:Quantity

I am assuming the LineTotal value is zero because at that point, the Price field was also zero.

Is this the best embed point(s) to be pre populating the pricing for the line items?  Should I be using a different validation embed point perhaps?

Note: These are the only two embedded bits of code in the entire browse procedure.


Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Browse not saving data back to database?
« Reply #4 on: February 11, 2014, 11:32:12 PM »
Hi Devan,

I think you are on the right track. But I'm curious why the price is _calculated_ in the browse? wouldn't that be calculated in the form when the record is added? Why would the browse recalculate it each time?

cheers
Bruce

Devan

  • Full Member
  • ***
  • Posts: 230
    • View Profile
    • Email
Re: Browse not saving data back to database?
« Reply #5 on: February 12, 2014, 12:16:17 AM »
Bruce,

Your questions are actually GREAT, because they are leading me in the right track to find out what is happening.

I remember now that we DO have a calculation routine in the form to calculate the price and line total, but it never worked 100% of the time.  So I worked around this by putting the price calculation routine in the browse as well, forgetting that the Browse procedure DOESN'T ACTUALLY SAVE the line item data.  So in effect, I was just masking the fact that the problem was there, and caused by the NetWebForm in the first place! :)

Now, the NetWebForm really only has two changeable fields, the Product Code (which is always called from a lookup button), and the quantity.  I have set the code in the Validate::LIN:Quantity embed point to calculate the Price and LineTotal, but as I mentioned - it doesn't always seem to fire.  I think it may be depending on whether the user [Tabs] out of the quantity field, or whether they just hit the [Save] button immediately after keying in the quantity.

Need to find a better embed point to do the calculation, I think...

Cheers,
Devan

Devan

  • Full Member
  • ***
  • Posts: 230
    • View Profile
    • Email
Re: Browse not saving data back to database?
« Reply #6 on: February 12, 2014, 12:21:58 AM »
EDIT: Actually, I just checked the NetWebForm, and I must have been getting really stressed at it not working, because I have the price calculation routine called on the:

Validate::LIN:Price (even though this field is read only)
Validate::LIN:ProductCode
Validate::LIN:Quantity
PreInsert
ValidateAll
ValidateInsert

embed points within the form !!! :)



Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Browse not saving data back to database?
« Reply #7 on: February 12, 2014, 01:55:05 AM »
Hi Devan,

>> I think it may be depending on whether the user [Tabs] out of the quantity field, or whether they just hit the [Save] button immediately after keying in the quantity.

I'm reasonably sure it fires every time - BUT of course it may fire _after_ the SAVE because the immediate validation is a separate thread to the Save button press.
the correct place to embed the code is thus in the ValidateValue::Lin:Quantity routine.
That is called during immediate validation, and also when the Save button is pressed.

Having it in too many places is probably not ideal because you can easily end up overwriting a correct value with an incorrect value.

Cheers
Bruce
Cheers
Bruce