NetTalk Central

Author Topic: Update a record while it is shown on a form  (Read 3068 times)

Poul Jensen

  • Full Member
  • ***
  • Posts: 191
    • View Profile
    • Email
Update a record while it is shown on a form
« on: January 14, 2024, 08:44:48 AM »
Hi,

I have a NetWebForm with a record and a button.
When I click the button I run some code that changes the record shown using embed Validate::Field Routine --> 5 Add server side code here.
That works fine, and the record on disk is updated.

If the user then clicks the save button, the old values are saved and overwriting the values I have saved.

I have tried in above embed to set the screen values by p_web.SSV('Field'), but that does not update the values shown.

How to get around this?

tia
/Poul

Richard I

  • Sr. Member
  • ****
  • Posts: 400
    • View Profile
    • Email
Re: Update a record while it is shown on a form
« Reply #1 on: January 14, 2024, 02:09:49 PM »
Hi Poul,
Would refresh work?
Cheers
Richard

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Update a record while it is shown on a form
« Reply #2 on: January 14, 2024, 10:34:05 PM »
are the values you are updating (and saving away) on the form itself?
or just other values in the record?

Are you aware that the "server side" code will run when the user clicks on "save"?
So your "updating code" will run here as well?

Personally I would not "interim" save the record before the user clicks on save, because it would make the "cancel" into a "sort-of" cancel.
So I think your root pattern is wrong anyway. Perhaps change your pattern so the correct values are set into the record, and session-values, but you don't actually save the record in the "server side code".

Poul Jensen

  • Full Member
  • ***
  • Posts: 191
    • View Profile
    • Email
Re: Update a record while it is shown on a form
« Reply #3 on: January 14, 2024, 11:10:19 PM »
Thanks Richard and Bruce,

are the values you are updating (and saving away) on the form itself?
or just other values in the record?

Are you aware that the "server side" code will run when the user clicks on "save"?
So your "updating code" will run here as well?

Personally I would not "interim" save the record before the user clicks on save, because it would make the "cancel" into a "sort-of" cancel.
So I think your root pattern is wrong anyway. Perhaps change your pattern so the correct values are set into the record, and session-values, but you don't actually save the record in the "server side code".

I am not convinced that the code is run twice - when I click the button and when the record is saved.
Because this is what I am doing in the event:
- Make a new workorder (child record of the record shown)
- Updating a date field on the record shown to the next date to be serviced.

And there is only one new child record created.

So what is NOT working is setting the date field on the shown record.

The code is this:

Code: [Select]
   MCus:NaesteCheck  =  MSagH:Lev_Dato_start + int(MCus:Interval * 30.4166)   
   p_web.SSV('MCus:NaesteCheck  ', MCus:NaesteCheck  )
   Access:MobCustomers.Update()


I would have thought  that the p_web.SSV('') would update the screen value but it does not.

So I guess my real questions is:  how can I update the screen value from an embed?
Or - as Richard suggests: how can I refresh the shown record with the disk values?

/Poul
 

Poul Jensen

  • Full Member
  • ***
  • Posts: 191
    • View Profile
    • Email
Re: Update a record while it is shown on a form
« Reply #4 on: January 15, 2024, 07:13:34 AM »
So easy  :-[

If I place the fields to update on the Field --> Client side --> Reset list then all works as expected.

/Poul